Skip to main content Skip to footer

How To: Get the Filtered Out Row Collection in C1DataGrid

In series of How To articles, this blog provides a small utility code implementation to retrieve the rows which have been filtered out of C1DataGrid for Silverlight. In few of the recent queries from our Silverlight users, they asked for a method to get the rows which have been filtered out of the grid. After filtering you can get the rows which have been filtered and available in the grid. However, there is no direct feature which gives you the row collection which did not meet the filter criteria. Now, it's not difficult to get this row collection. Your first thought probably would be to loop through the rows and check their visibility. However, you will soon realize that C1Datagrid has only that collection of the rows which meet the filter criteria. A very simple option is to use LINQ to get a quick and fast retrieval of the records. The following steps will help you out with the implementation :

  1. Get the underlying DataItem (custom data object) for the rows in C1DataGrid after filtering.
  2. Loop through the actual DataSource of C1DataGrid and skip out the records retrieved in step 1.

See the code snippet below : C# code


  var list = from rw in c1DataGrid1.Rows select rw.DataItem as PersonName;  
  var filterList = from rw in dataList where !list.Contains(rw) select rw;  

  MessageBox.Show("Number of Records Filtered Out: " + filterList.Count().ToString());  

VB Code


  Dim list = From rw In c1DataGrid1.Rows Select CType(rw.DataItem, MyDataClass)  
  Dim filterList = From rw In myDataList Where Not list.Contains(rw) Select rw  

  MessageBox.Show("Number of Records Filtered Out: " & filterList.Count().ToString())  

Refer to the attached samples for complete implementation. Download Sample C# Download Sample VB

MESCIUS inc.

comments powered by Disqus