Currently, ASPxGridView displays total count of visible rows in its pager. It is not a problem if there is no grouping since the ASPxGridView displays only data rows. However, if grouping is applied, the pager counts group rows too. As a result, the total count of displayed items is not equal to the total count of records in a data table.
I have created this request to initiate a detailed research of the capability to additionally display a real count of rows in a bound data table.
Meanwhile, you can use solutions demonstrated in the the following resources:
ASPxGridView - How to return the number of visible data rows excluding group rows
How to get the number of data rows in a filtered or grouped ASPxGridView
I have written this as an extension method.
It expects that a KeyFieldName is set if it should work…
Feel free to steal this ;-)
public static void FixGridItemCount(this ASPxGridView grid) { if (string.IsNullOrWhiteSpace(grid.KeyFieldName)) { return; } grid.DataBound += FixGridItemCountEventHandler; grid.PreRender += FixGridItemCountEventHandler; grid.BeforeGetCallbackResult += FixGridItemCountEventHandler; var firstKeyFieldName = grid.KeyFieldName.Split(';').FirstOrDefault(); if(firstKeyFieldName != null) { grid.TotalSummary.Add(new ASPxSummaryItem { FieldName = grid.KeyFieldName, SummaryType = SummaryItemType.Count, }); } } private static void FixGridItemCountEventHandler(object sender, EventArgs e) { var grid = sender as ASPxGridView; if(grid != null) { if (string.IsNullOrWhiteSpace(grid.KeyFieldName)) { return; } var firstKeyFieldName = grid.KeyFieldName.Split(';').FirstOrDefault(); if (firstKeyFieldName != null) { var asPxSummaryItem = grid.TotalSummary[firstKeyFieldName]; if (asPxSummaryItem != null) { var itemCount = (int) grid.GetTotalSummaryValue(asPxSummaryItem); grid.SettingsPager.Summary.Text = MembercareGlobal.GridViewPagerSummaryText.Replace("[itemCount]", itemCount.ToString()); } } } }
I second the request to add an option to display the real row count, instead of the "item" count.
The confusion may also be caused by the incorrect translations of pager labels to other languages.
See for example "Incorrect Russian translation of the GridView pager labels" (https://www.devexpress.com/Support/Center/Question/Details/T315109)
Any news about this one?
It's been three years!
Bo Johansen
Hello Bo,
I apologize for the delayed answer. Thank you for your comment. This functionality is not implemented in our controls at the moment. It requires a lot of changes in the grid and we can't introduce this feature in the near future. However, we are always trying to improve our controls and we will discuss this inquiry. But I can't provide you with any ETA as to when it will be implemented.
The provided solution found here: ASPxGridView - How to return the number of visible data rows excluding group rows works except for when you select "All" for the page size option. How do we fix the problem when "All" is selected?
Hello Dustin,
Thank you for contacting us. We will research this issue in the context of the T559078: Real count of records in the ASPxGridView even when a grouping is applied in case of "All" page size option thread. It has been placed in our processing queue and we will update it once we have any results.
Any news about when will be fixed?
Hello Filippo,
At the moment I cannot provide you with any time frames as to when this behavior will be changed out of the box. I recommend you use an approach from the ASPxGridView - How to return the number of visible data rows excluding group rows example.
Regards,
Vova