DevExpress XtraGrid v12.2 GetTotalSummary - c#

I am implementing IListServer. Everything works fine except GetTotalSummary. All examples that I've been able to find show the implementation of GetTotalSummary returning a Dictionary of items. In version 12, the interface for IListServer has changed and no longer returns a dictionary. Instead, it returns a List<objects>.
An example implementation of the interface is given here, but unfortunately the specific method that I need is not implemented.
I don't know how to fill this returning list so that I can see my records' count in grid footer. Any help is really appreciated :)
And here is my ascx for the dynamic grid I am filling:
<dx:ASPxGridView runat="server" Width="100%" ID="grdMain" ClientInstanceName="grid"
KeyFieldName="ID" AutoGenerateColumns="false" EnableRowsCache="false"
OnAutoFilterCellEditorCreate="grid_AutoFilterCellEditorCreate" OnAutoFilterCellEditorInitialize="grid_AutoFilterCellEditorInitialize" OnProcessColumnAutoFilter="grid_ProcessColumnAutoFilter">
<settingsbehavior allowfocusedrow="true" allowclienteventsonload="false" AllowGroup="false" autoexpandallgroups="true"
enablerowhottrack="True" columnresizemode="Control" />
<settings showverticalscrollbar="true" verticalscrollableheight="500" showgrouppanel="false"
showfilterrow="true" ShowHorizontalScrollBar="True" showfooter="True"/>
<styles>
<AlternatingRow Enabled="true" />
<Row Cursor="pointer" />
</styles>
<clientsideevents init="SGEntityListScript.OnInit" endcallback="SGEntityListScript.OnEndCallback" />
<SettingsBehavior EnableCustomizationWindow="true" />
<TotalSummary>
<dx:ASPxSummaryItem FieldName="ID" SummaryType="Count"/>
</TotalSummary>
</dx:ASPxGridView>

The last parameter of the IListServer.Apply method is the list of total summary descriptions requested by the control. Save them locally or immediately evaluate and save results. The GetTotalSummary method should return array of total summary values in the same order as they were requested in the Apply method.

Related

ASP.Net Gridview Not Allowing Rows To be Selected After Certain Value In DataKey

I've been utilizing what I call, "drag, drop and configure" programming for years to create very simple ASP.net forms to collect data for my organization. Basically, I'll drag a datasource into my design view, configure it, and then I'll drag a gridview into the design view and then configure it, etc., etc.
Yesterday, I encountered a behavior I have never seen. My gridview is set to allow row selection. Everything seemed to be working normally until I happened to click on a row that didn't "select" (didn't highlight itself, etc.). And, then I started clicking on other rows and found more that couldn't be selected. Again -- it's not all the rows...just some. i.e. some can be selected and others can't.
After a lot of troubleshooting, the only thing I've been able to determine is that above a certain datakey value -- rows won't select. In this case, its datakeys with values around and > 40,000. Anything below that, and the rows select and the other parts of the form load just fine. The fact that it works for all records with datakeys below a certain value is really stumping me as to what rock to look under next -- hence, actually creating a stackoverflow account and posing the question.
Code for the gridview is below. It does live within an update panel if that matters. Also provided the code behind, though it's not really doing anything of consequence.
Note:
The datakey that seems to be controlling the behavior is a unique identifier for an application within a set of applications. It's not an incremental identity. --- if that helps.
The form is hooked into a database for the select statement and is pulling records from a view to populate the grid.
I'm tempted to show all of my code including the database side and stored procs -- thinking maybe I'm making rookie mistakes with data typing, etc. --- BUT --- I'm pausing there because the gridview selection IS WORKING -- just not above datakeys around and above 40,000
Lastly, when you attempt to select an item with a key > 40,000 the grid will no longer sort by columns or allow you to click a different page. Similarly, if you sort the grid FIRST by applicationID (the datakey) -- all the pages with datakeys > 40,000 are not clickable i.e. pagination for those pages do not work
EDIT --- DANG IT!!! I posted the wrong code behind. I replaced it with the right one. UPDATE: It looks like it's related to the panels. When I comment them out --- it works. When they are included -- the rows in question (keys > 40000) aren't selectable. All this code does is control visibility of panels. How could visibility properties make this kind of impact....weird
Pic of Issue:
<ContentTemplate>
<strong>
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
Select AIT by using search box below or by sorting and paging through AIT table.<br />
<br />
Search: </strong> <asp:TextBox ID="TxtAITSearch" runat="server"></asp:TextBox>
<asp:Button ID="btn_Search" runat="server" OnClick="btn_Search_Click" Text="Search" />
<em>
<br />
*wildcard searches for AIT number, AIT Name or AIT Manager may be used</em><asp:HiddenField ID="hdnApl_ID" runat="server" />
<asp:HiddenField ID="hdn_StandardID" runat="server" />
<asp:HiddenField ID="Hdn_AlignmentID" runat="server" />
<asp:HiddenField ID="hdn_Attribute" runat="server" />
<br />
<asp:GridView ID="gvAITSelect" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" DataKeyNames="applicationID" DataSourceID="DSGetSearchView" GridLines="Vertical" OnSelectedIndexChanged="gvAITSelect_SelectedIndexChanged" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="applicationID" HeaderText="App ID" SortExpression="applicationID" />
<asp:BoundField DataField="fullName" HeaderText="Application" SortExpression="fullName" />
<asp:BoundField DataField="Alignment" HeaderText="Alignment" SortExpression="Alignment" />
<asp:BoundField DataField="AlignmentID" HeaderText="AlignmentID" SortExpression="AlignmentID" Visible="False" />
<asp:BoundField DataField="status" HeaderText="Status" SortExpression="status" />
<asp:BoundField DataField="relatedAssociates_2_displayName" HeaderText="App Mgr" SortExpression="relatedAssociates_2_displayName" />
<asp:BoundField DataField="relatedAssociates_3_displayName" HeaderText="Tech Exec" SortExpression="relatedAssociates_3_displayName" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
protected void gvAITSelect_SelectedIndexChanged(object sender, EventArgs e)
{
lbl_Alignment.Text = gvAITSelect.SelectedRow.Cells[3].Text;
Hdn_AlignmentID.Value = gvAITSelect.SelectedRow.Cells[4].Text;
string strAITvalue = gvAITSelect.SelectedRow.Cells[1].Text;
hdnApl_ID.Value = strAITvalue.ToString();
//panel_RoleDetails.Visible = true;
//panel_AITAlignment.Visible = true;
//panel_NoteDetails.Visible = true;
}
Ok -- I figured it out. And, the answer is, I'm a big dummy. Further, the fact that the grid stopped working around in and around 40000 should have been a big flashlight to me pointing the way. Pic of the issues
If you look at the pic I uploaded -- in the course of troubleshooting an earlier and unrelated issue -- I set the DbType (highlighted row) to Int16. In the available selections I don't see an unsigned Int16 -- so, this appears to be signed---Annnnnnnnnnnnnnnnd, of course, good developers know Int16s hold values up to 32,767. Guess what happened when I changed it back to the default "Object"? Yup. It worked. So the problem not at all weird or strange. Instead, very much a rookie mistake.
All this said -- good learning experience. Additionally, #Albert D. Kallal and #fnostro you both gave me some good understanding on some things for the future. I appreciate both of you trying to help me. And, now I also, have a stackoverflow account :)
Thanks again.

Telerik RadGrid Culture setting not working

I was expecting that the property Culture of the radgrid can be used to set the culture of the grid and this reflect also the data displayed in its cells, right?
But in this Grid:
<telerik:RadGrid ID="GrdWaypoints" runat="server" Width="550px" AutoGenerateColumns="False" Culture="en-US"
AllowAutomaticUpdates="false" AllowAutomaticInserts="false"AllowAutomaticDeletes="false"
OnDeleteCommand="GrdWaypoints_DeleteCommand"OnInsertCommand="GrdWaypoints_InsertCommand" OnUpdateCommand="GrdWaypoints_UpdateCommand"OnItemDataBound="GrdWaypoints_ItemDataBound"
GroupPanelPosition="Top" OnNeedDataSource="GrdWaypoints_NeedDataSource">
<ClientSettings AllowDragToGroup="false">
<Scrolling AllowScroll="false" UseStaticHeaders="false" />
</ClientSettings>
<GroupingSettings ShowUnGroupButton="false" />
<MasterTableView ShowGroupFooter="False" Width="100%" DataKeyNames="WaypointID"EditMode="InPlace">
<Columns>
<telerik:GridNumericColumn UniqueName="Longitude" HeaderText="Longitudine"DataField="Longitude" DecimalDigits="6" DataFormatString="{0:#0.000#}" ></telerik:GridNumericColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
... no matter what I specify in the culture property, the numbers, in the longitude GridNumeric column, are always displayed based on the number format specified in the regional settings of the server.
And obviously, on the Insert and Update command, everything goes in error if the user types the number in a different culture from the server.
Does anyone know a workaround for this bug?

How to display alternative color in datagridview if it is empty?

The Alternative BackColor property works if there is data in datagridview . I want to show Alternative BackColorif it is empty.
When declaring your GridView, you can configure options in the EmptyDataRowStyle and the EmptyDataRowStyle elements. So I suppose you can assign the same value to the BackColor in both EmptyDataRowStyle and AlternatingRowStyle elements like in the sample below.
<asp:GridView runat="server" ID="myGridView">
<EmptyDataTemplate>No data</EmptyDataTemplate>
<EmptyDataRowStyle BackColor="Red" />
<AlternatingRowStyle BackColor="Red" />
</asp:GridView>

Telerik RadHtmlChart group series by column value

I'm making a pretty simple polling app. Users text a certain number with the values 'yes' or 'no' and the results show up live via AJAX on a projector. There are five different items to vote on (all yes or no).
Right now I have a SQL View that returns [poll_name, vote_value, value_count] where vote_value is either 'yes' or 'no'.
Using RadHtmlChart, I'm trying to display a stacked BarChart with a bar for each poll_name, a red bar for no votes and a blue bar for yes votes. I tried to alter the code from the BarChart example and merge it with the SqlDataSource example:
<asp:SqlDataSource ID="sqlResults" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB %>"
SelectCommand="select poll_name, vote_value, value_count from vw_sms_pollResults order by poll_id" />
<tel:RadScriptManager runat="server" ID="rsmScriptManager" />
<tel:RadAjaxPanel runat="server" ID="rapPanel" LoadingPanelID="ralpLoadingPanel" EnableAJAX="true">
<tel:RadHtmlChart runat="server" ID="rhcResults" Width="800" Height="500" Transitions="true" DataSourceID="sqlResults">
...
<PlotArea>
<Appearance>
<FillStyle BackgroundColor="White" />
</Appearance>
<XAxis DataLabelsField="poll_name">
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</XAxis>
<YAxis AxisCrossingValue="0">
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</YAxis>
<Series>
<tel:BarSeries Stacked="true" DataFieldY="value_count">
<Appearance FillStyle-BackgroundColor="Red" />
</tel:BarSeries>
</Series>
</PlotArea>
</tel:RadHtmlChart>
</tel:RadAjaxPanel>
Unfortunately, I end up with twice as many bars as I want: a 'yes' and a 'no' for each poll_name, they're all the same color (obviously), and they're not stacked. Ideally I would be able to tell it create a new BarSeries for each value of (ie, group by) vote_value.
How should I go about either massaging the data or changing my markup to fix this? In the future I'd like to allow an arbitrary number of responses, so I'm loathe to changing my query to simply have a 'yes_count' and 'no_count' columns, but I may have to in the meantime.
To stack series, you need at least two: http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/stackedseries/defaultcs.aspx
One should have the YES votes for its values (i.e., the field provided in the DataFieldY property should have that number for each item on the x-axis). The other should provide the same for the NO votes.
Thus, you should have something like:
<Series>
<tel:BarSeries Stacked="true" DataFieldY="value_count_Yes">
<Appearance FillStyle-BackgroundColor="Red" />
</tel:BarSeries>
<tel:BarSeries Stacked="true" DataFieldY="value_count_No">
<Appearance FillStyle-BackgroundColor="Blue" />
</tel:BarSeries>
</Series>
I am not sure how your data is structured, so I am not sure how you can obtain this data. Perhaps you can generate a dynamic field in the SQL query itself that subtracts the yes votes from the total votes if that's what you have.

Data Binding to an XML file

I have an XML file structured as follows:
<Levels>
<Level Code="T" Text="Test">
<SubLevels>
<SubLevel Type="9" Text="Nine"/>
<SubLevel Type="8" Text="Eight"/>
<SubLevel Type="7" Text="Seven"/>
<SubLevel Type="6" Text="Six"/>
</SubLevels>
</Level>
<Level Code="T2" Text="Test 2">
<SubLevels>
<SubLevel Type="1" Text="One"/>
<SubLevel Type="2" Text="Two"/>
</SubLevels>
</Level>
</Levels>
What I want is two drop down lists, one linked to /Levels/Level and one to the SubLevels for the selected level. Currently, I have the main one bound as follows:
<asp:XmlDataSource ID="XmlLevelInfo" runat="server" DataFile="~/Levels.xml">
</asp:XmlDataSource>
<asp:DropDownList ID="cboLevelFilter" runat="server"
DataSourceID="XmlLevelInfo" DataTextField="Text" DataValueField="Code">
</asp:DropDownList>
This works fine, but I can’t work out how to link the Sub Levels to the second drop down list. Is this possible using data binding?
I would expect that the XmlDataSource for your second drop-down would need to have it's XPath varied on SelectedItemChanged of the first.
Such that it's XPath might look like:
//Level[#Code = '<CODE VALUE FROM SELECTED ITEM>']//SubLevel
You'd probably also want to initially just bind it with all SubLevels such that the XPath might look like: //SubLevel
Then it'll take a little extra effort to AJAX-ify it all for a nice experience... (Don't forget to set AutoPostBack to true on the first drop-down!)

Categories