ant-design-blazor icon indicating copy to clipboard operation
ant-design-blazor copied to clipboard

Table: Determine totals row (SummaryRow) using filter?

Open true-perfect-code opened this issue 1 year ago • 1 comments

Dear Ant-Team,

Is it somehow possible to use only the filtered entries in the total in a table in which you use totals rows?

Currently I calculate the sum in a table by displaying the sum of the entire list displayed in the table using "SummaryRow" (e.g. list.Sum(...)). The problem occurs when the user sets filters, then of course my sum is no longer correct.

Thanks pc

true-perfect-code avatar Apr 03 '24 19:04 true-perfect-code

Hello @true-perfect-code , you can use ITable.GetQueryModel() to get the filtered rows and calculate the sum.

ElderJames avatar Apr 05 '24 14:04 ElderJames

    void GetSum()
    {
        var queryModel = Table.GetQueryModel() as QueryModel<Data>;

        var query = queryModel.ExecuteQuery(DB.Items);

        var sum = query.Sum(x=> x.Num);
    }

ElderJames avatar Jun 20 '24 15:06 ElderJames

Thanks @ElderJames

true-perfect-code avatar Jun 20 '24 15:06 true-perfect-code