Hello,I'm using the XamDataGrid with DataSource containing a list of comma-separated strings. By default the filter row dropdown includes all items presented in grid. But in this case I would like to bind the filter dropdown to other property of viewmodel containing just the values which are presented in the grid as strings. Is there a way to do this? For better understanding I made a screenshot of how the dropdown looks currently:
What I want is that the dropdown contains each item (F01, F02 etc.) only once.Thanks in advance and kind regards,Daniel
Hi Daniel,
You can handle the RecordFilterDropDownOpening event in the XamDataGrid. Inside the event arguments you have access to the drop down items and can modify or remove them, or you can add your own as well.
http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v14.2~Infragistics.Windows.DataPresenter.DataPresenterBase~RecordFilterDropDownOpening_EV.html
This gives you complete control over what is displayed inside the dropdown.
Hi Rob,I've tried that and it's not an option for me: I only have about 180 items in the grid and if I work with this event and try to delete existing filter items first and then fill the items I need its takes the dropdown about 30 seconds to open. Even if I'm not deleting existing items and just add 100 more it takes about 15 seconds which is incredibly slow. Do you have any other ideas? I think there has to be some way to change the data source for the filter drop down.Regards,Daniel
Do you mean how do you access your view model from the style? The RecordFilterTreeControl contains a Field property. From here you can access the DataContext of the XamDataGrid which I would imagine is your view model.
"{Binding Field.Owner.DataPresenter.DataContext, RelativeSource={RelativeSource TemplatedParent}}"
Hi Rob,
thank you, that worked! I have one more question for you: if I implement a property in my ViewModel (a list of strings) and set this property as TreeItems in the control template for the filter this items are not recognized as filter items (I've actually expected that). The question is: is there a simple way to convert them to filter items or should I make a list of checkboxes and implement the filter in code-behind (if yes, how do I set the filter of a XamDataGrid programmatically).Thanks in advance,Daniel
Hi Daniel
I don't quite understand what you have so far. When you say TreeItems do you mean the ItemsSource of the tree control? Although yes I would also expect that they wouldn't be recognized as filter items. I think adding the filters programmatically would be the simplest approach since adding a filter is pretty straight forward. This doc shows how you can add filters programmatically: http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamDataPresenter_Add_Filter_Conditions.html
Let me know if you have any further questions on this matter.
Hi Rob,that worked, thank you!Regards,Daniel