How to get a count of the filtered records in the grid

I am trying to get a count of the filtered records in an sfDataGrid. However, when I use the event and code below, the value returned is the count of the total in the datasource, not the filtered count.


        private void TransactionHistoryListDataGrid_FilterChanged(object sender, Syncfusion.WinForms.DataGrid.Events.FilterChangedEventArgs e)

        {

            var filteredRecords = TransactionHistoryListDataGrid.View.Records.Select(x => x.Data).Count();

            ShowFilteredRecordCount(filteredRecords);

        }


I also tried  var filteredRecords = TransactionHistoryListDataGrid.View.Records..Count; but got the same results.

For example, when I initially populate the grid from the datasource, it this example, I would see total records in the datasource result as 36. But when the user applies a column filter, in this example, finding one 1 qualifying record, the result of the code above still shows 36 records.

What am I missing?






Attachment: SyncFusion_Screenshots_beefcbb9.zip

1 Reply

VS Vijayarasan Sivanandham Syncfusion Team September 30, 2022 04:52 PM UTC

Hi David Adler,

We have prepared the simple sample and checked the reported issue “filtered records count not updated properly in the grid” and are unable to replicate the issue from our end. It is working fine as expected. Please find the tested sample and video in the attachment.

Please have a look at this sample and let us know if we have missed any customization done in your application. Otherwise, try to reproduce the reported issue in this sample and revert to us with the modified sample and steps to replicate the issue. It will be more helpful for us to find the exact cause of the issue and to provide a prompt solution.

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_And_Video_9660644e.zip

Loader.
Up arrow icon