I would like to allow the user to filter the records that appear in the data grid. The main way in which I have done this previously is to use the ICollectionView interface. So I am using CollectionViewSource.GetDefaultView(IList<MyRecordClass>) and setting that ICollectionView as the grid's DataSource. It filters the items fine, but I get an error once I click on the record. Basically, if I had selected a record before, and the filtered few does not include the previously selected record, clicking on any other record using the new filter will make the old record show up. Wow. That soudns awful. Let me provide an example to illustrate:
Assume I have two records with one column each: [Record] and [Thing]. I use the ICollectionView interface and set the member as the DataSource. Assume the user initially sees the two records and click on [Record]. He modifies a field and then uses my custom user control to filter the grid. He writes Thing, and the grid now only shows the record [Thing]. The user goes to click on the record. When he does, the value "Thing" turns into "Record". Clearly, not the desired behavior. I have added additional logic that sets the grid's ActiveRecord and ActiveCell to null in the event that the current ActiveRecord is filtered out, but that doesn't seem to help.
Any ideas? Should I be using some other kind of container for easy filtering ?
Thanks!
-Szymon
Hello Szymon,
I'm so sorry this post was lost and not responded to.
Were you ever able to get filtering to work with the xamDataGrid when binding to a collection?
WPF supports filtering on a CollectionView. Unfortunately, this object is not accessible in the XamDataGrid. Check out the following post for one work-around to this:
http://news.infragistics.com/forums/p/11723/44226.aspx#44226
Most WPF books and several blogs describe how to apply a filter to a list box collection. This is the same type of filter you would apply to the XamDataGrid using the work-around posted in the above post.
Thanks,
Hi Curtis
Is the workaround still valid or is there a fix for this?
Phil
Hi Phil,
Absolutely. WPF Filtering is a valid way to filter any collection.
In addition to that approach, the latest version of NetAdvantage for WPF (version 9.1 and higher) now supports Record Filtering. Check out the Feature Browser for this control to see how it works. This feature is now a standard feature for the XamDataGrid.
Thank you,
Curtis