I am using an NetAdvantage 13.1 Win CLR4x UltraGrid. In my grid, I have 10 columns. I am attempting to make 5 of these column's LogicalOperator set to Or, and the other 5 set to And, but is not working as exected.
In my InitializeLayout, I have this:
e.Layout.Override.FilterUIType = FilterUIType.FilterRow;
var band = ugCustomerList.DisplayLayout.Bands[0]; band.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
band.ColumnFilters[3].LogicalOperator = FilterLogicalOperator.Or; band.ColumnFilters[4].LogicalOperator = FilterLogicalOperator.Or; band.ColumnFilters[5].LogicalOperator = FilterLogicalOperator.Or; band.ColumnFilters[6].LogicalOperator = FilterLogicalOperator.Or; band.ColumnFilters[7].LogicalOperator = FilterLogicalOperator.Or;
This does not work for what I need. I would like the filter operation to work like this:
column0 AND column1 AND column2 AND (column3 OR column4 OR column5 OR column6 OR column7) AND column8 AND column9
There are several different ways to skin this cat; given that you have 10 different conditions, I found it easiest to implement a custom class that derives from FilterCondition, and add that condition to the ColumnFilter.FilterConditions collection for one column (actually doesn't matter which column).
Note that this example adds the filter on a button click, which means it is not available in the filter dropdown. It is possible to do that, so if you need direction on that let us know.
Sorry for the late reply, but this is getting close to what I need. Currently, I have created the custom filter condition, and on BeforeRowFilterChanged, I call a method to set the custom filter.
private void ugCustomerList_BeforeRowFilterChanged(object sender, BeforeRowFilterChangedEventArgs e) { SetFilter(); }
private void SetFilter() { if (ugCustomerList.DisplayLayout.Bands[0].ColumnFilters[0].FilterConditions.Count == 0) { var colCount = ugCustomerList.DisplayLayout.Bands[0].Columns.Count; ugCustomerList.DisplayLayout.Bands[0].ColumnFilters[0].FilterConditions.Add(new MyFilterCondition(colCount)); } }
So the MyFilterCondition seems to be working properly, and returning true for rows that I expect, and returning false for rows that don't meet the condition, but after the filter is set, some rows that should be visible don't. My best guess currently is that MyFilterCondition is being applied, but being overwritten by the normal filter operation. Is there a way around this?
Thanks for the help.