Yalda
Yalda

Reputation: 684

Showing record count in DevExpress XtraGrid v12.2

Below is part of my base EntityList class which contains a grid. The grid will be filled with columns and rows depending on child entities later. I need to show the number of rows on the grid's footer, and thus I am using TotalSummary.

<dx:ASPxGridView runat="server" ID="grdMain" ClientInstanceName="grid" 
        KeyFieldName="ID" AutoGenerateColumns="false">                                   
    <settings showfooter="True"/>
    <TotalSummary>
        <dx:ASPxSummaryItem FieldName="ID" SummaryType="Count"/>
    </TotalSummary>
</dx:ASPxGridView>

The problem is, in different entities that use this base class, I have different names for the ID column, such as InvoiceID, CustomerID, etc. So, how to tell the grid what Count I want it to show? Even if I had the same name for the specified column, that column would not be visible in the grid, thus it's TotalSummaryItem showing the count of that column, would not be seen on the grid.

Is there any way to tell the grid I need it to show the Count of rows, not a specified column with a fixed name?

Any ideas how to solve this problem??? Many thanks!

P.S. if it helps, I am implementing IListServer in a DataObject class

Upvotes: 1

Views: 792

Answers (1)

Moha Dehghan
Moha Dehghan

Reputation: 18443

The documentation for FieldName property does not tell anything about this, but it says something important that can help solve the problem.

By using Custom for the value of SummaryType property and handling CustomSummaryCalculate event, you have complete control over how the summary item is being calculated. Handle the event and count the rows, however you want.

Another option is to add the summary item in code, where you know the name of the columns. I guess when you are creating the grid and supplying its data, you can find the name of the desired column.

Upvotes: 1

Related Questions