Hello,
I have 2 xamdatafrids that are binded to the same DataSource.
Each Datagrid have different subset of fields. One binded to properties A,B and the other to C,D.
I want to be able to filter field A and get both table be filters.
So if after the filter I get 2 records I want to see the same 2 records in the second table.
I don't want to use hiding of fields, because my original table have much more fields.
I'd appreciate your help.
Anna.
Hi Anna,
The default filtering that the XamDataGrid provides won't be able to give you this functionality because the default filtering is tied to fields. That is to say, if you filter grid 1 by field A and since grid 2 does not have it's own field A, applying the same filter to both will only affect grid 1. This is where external filtering comes in. You can use an ICollectionView to perform the filtering and since both grids will be bound to the same collection view, any filter applied to it will be displayed in both grids. I attached a quick sample to demonstrate this. You will see that when filtering on one grid, the other grid will react and filter as well, even though the types of fields they have are different.
Hi Rob,
Thanks a lot for the quick reply.
This is very helpful.
Do you know why it doesn't work with FilterLabelIconDropDownType="MultiSelectExcelStyle" ?
When I'm setting FilterLabelIconDropDownType="Default" it works fine.
In addition,
When I set filter in one table, the filters in the second table are not working.
Can it be fixed in some way?
I found out that this solution won't work for me because I'm using UnboundFeilds.
So I'm trying to add all fields to both tables but those I don't want to see I hide.
So when I set a filter in one table I want to transfer the same filter to the other table.
Is there a way to do that?
CollectionView filtering can only filter data that exists within the collection it has. UnboundFields imply that you have columns that are not associated with any underlying data so filtering on those columns is not possible, since they don't exist in the ICollectionView. I think your only option here is to have hidden columns in your grids. You can't use ICollectionView because of UnboundFields. Make sure the columns used for filtering exist in both grids and then once a filter has occurred to one grid, programmatically apply that filter to the other grid. The RecordFilterChanged event will help you there.