Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1170
Add cell value FilterDropDownItems to RecordFilter DropDownItems list
posted

We're using a XamDataGrid to display the first 100 rows from a database query, and when a user enters a new grid filter we catch it and include it in the query, so they will still see at least 100 rows, instead of just filtering the items in view. This works fine.

What I'd like to do is add to the filter cell dropdown any items that aren't already represented by one of the grid's rows. I have a list of all values for a given column, and I'm handling the RecordFilterDropDownPopulating event to try and add those items to the e.DropDownItems collection. 

The problem I'm having is that this is a collection of FilterDropDownItems, and in the constructor you have to specify a condition, special operand, or command. I know that the object has a flag called IsCellValue, and I'm guessing that's what I actually need to be true in order for my new FilterDropDownItems to work properly. Is there any way to create a FilterDropDownItem that behaves like the automatically added cell value items?

Parents
No Data
Reply
  • 34510
    Offline posted

    Hello John,

    For an example of how to provide your own filter items to the drop down list please see the following article: http://help.infragistics.com/doc/WPF/2013.2/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v13.2~Infragistics.Windows.DataPresenter.DataPresenterBase~RecordFilterDropDownPopulating_EV.html

    As you can see, you have to provide a ComparisonCondition to the FilterDropDownItem constructor.  There is no way at this time that would allow you to add a filter item without providing one of the arguments you specified (condition, operand or command).  Now I presume that your issue with this is that you can't find where to get the ComparisonOperator that the ComparisonCondition needs.  While there is no property that you can use for this, it's still possible to grab the current operator.  For this I created a dictionary where the key and value are Field and ComboBox.  I then created a style targeting FilterCellValuePresenter and handled the Loaded event.  Inside the Loaded event I searched the visual tree for the ComboBox responsible for holding the different operators.  I then stored the ComboBox inside the dictionary so I could reference it later in the RecordFilterDropDownOpening event.  I've attached a sample that demonstrates this.

    Keep in mind that this code will only work when using the basic record filtering.  If you are using excel style filtering, the combobox code will not work.  You will have to provide a ComparisonCondition with a pre-chosen operator.

    WpfApplication1.zip
Children