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 :
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