To change the number of visible data rows excluding group rows, do the following:
- Define the TotalSummary item:
[ASPx]<TotalSummary><dx:ASPxSummaryItemFieldName="City"SummaryType="Count"ShowInColumn="City"DisplayFormat="{0} Item(s)"/></TotalSummary>
- Handle the grid's BeforeGetCallbackResult, PreRender, and DataBound events;
- Call the ASPxGridView.GetTotalSummaryValue to obtain the number of rows;
- Set this value as SettingsPager.Summary.Text.
Question Comments
Added By: Groupcare A/S at: 10/22/2015 11:06:54 AM
I have written this as an extension method.
It expects that a KeyFieldName is set if it should work...
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());
}
}
}
}
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T303554: ASPxGridView - How to return the number of visible data rows excluding group rows. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.