How to trigger a visible row count

Good day,

I have a grid being displayed which is continuously being updated from the backend. Rows are added and removed as well.
I am also applied various filters to hide certain rows.
I know the code to see the count of visible rows is as follows:


My problem is when to run this code. Which event triggers each time the display changes?

It cannot be any text or data changed events as the filters doesn't trigger them.
I though it might be the paint event but filters also doesn't trigger it.

Regards,
James

3 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team January 16, 2018 06:28 AM UTC

Hi James, 

Thanks for your interest in Syncfusion products. 

We could able to understand your scenario and you can use SourceListListChanged event which is not triggered while filtering the records and LastVisibleRow property of ViewLayout to get the last visible row index. Please make use of the below code and let us know if you have any queries, 

Code snippet: 
this.gridGroupingControl1.SourceListListChanged += new Syncfusion.Grouping.TableListChangedEventHandler(gridGroupingControl1_SourceListListChanged); 
 
void gridGroupingControl1_SourceListListChanged(object sender, Syncfusion.Grouping.TableListChangedEventArgs e) 
    if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted) 
    { 
        //Index of last visible row. 
        int lastRowIndex = this.gridGroupingControl1.TableControl.ViewLayout.LastVisibleRow; 
 
        //Gets the number of rows in view. 
        int rowCount = this.gridGroupingControl1.TableControl.ViewLayout.VisibleRows; 
    } 
 
Regards, 
Piruthiviraj 



JR James Roodt January 16, 2018 06:39 AM UTC

Hi Piruthiviraj,

Sorry for the misunderstanding but i need an event which will trigger for ANY change on what is displayed so the row count is always up to date.

This includes changes to the data source, built in filters (Excel and Dynamic) and programmatic filter.

Regards,
James


AR Arulpriya Ramalingam Syncfusion Team January 17, 2018 11:04 AM UTC

Hi James,   
   
Thanks for your update.   
   
We have analyzed your requirement. As per the GridGroupingControl current support, the SourceListListChanged event will be triggered whenever, the items are added/removed to/from underlying data source. The filtered records will be maintained in FilteredRecords collection and updated to grid when the records are filtered and the CategorizedRecords event will be triggered whenever the records are filtered. Moreover, the GridGroupingControl does not have a common event to identify that when the visible rows are changed. So, we would suggest you to use the SourceListListChanged event when the changes are done in underlying data source and CategorizedRecords event when the records are filtered, to get the last visible row index by using theGetRowIndex() method of the record. Please make use of the below code   
   
Code example   
   
//Event triggering   
this.gridGroupingControl1.CategorizedRecords += GridGroupingControl1_CategorizedRecords;   
   
//Event customization   
private void GridGroupingControl1_CategorizedRecords(object sender, TableEventArgs e)   
{   
    if (recordsCount != e.Table.FilteredRecords.Count)   
    {   
        recordsCount = e.Table.FilteredRecords.Count;   
        //Index of last visible row.    
        int lastRowIndex = e.Table.FilteredRecords[recordsCount].GetRowIndex();   
   
        //Gets the number of rows in view.    
        int rowCount = recordsCount;   
    }   
}   
   
Please let us know, if you have any other queries.   
   
Regards,   
Arulpriya   


Loader.
Up arrow icon