One of the columns of my UltraGrid uses a ValueList from int to string to display the record label on the screen for the related id as integer.
A record has the label "0830 (0800)". When I enter "08" in the filter of that column, that row is filtered out. The tooltip on the filter cell displays "Contains '8'".
I changed the column.FilterComparisonStyle to DisplayTextOnly, but this behavior is still the same.
My goal is to filter only for the DisplayText and ignore the values of the ValueList.
How can I accomplish this?
Thank you for the detailed answer, Mike.
I tried with the project you provided and see all kinds of unexpected behavior.
I added the following line of code in ultraGrid1_InitializeLayout.
ov.FilterOperandStyle = FilterOperandStyle.Edit;
And extended the value list with the following.
vl.ValueListItems.Add(5, "add 08:12");
When I enter '0' in the filter cell, the grid is completely empty. All rows are filtered. Expected values are "0830 (0800)" and "add 08:12".
When I enter '1' in the filter cell: Expected: "add 08:12". Actual: "Banana"
When I enter '2' in the filter cell: Expected: "add 08:12". Actual: "Cherry"
When I enter '3' in the filter cell: Expected: "0830 (0800)". Actual: "Grape"
When I enter '8' in the filter cell: Expected and actual values match: "0830 (0800)" and "add 08:12".
At this moment, I'm not allowed to make any changes to the functionality of the software, but only fix bugs.
Well... I'm a little confused. Maybe I wasn't clear, but if you are going to use either of the workarounds I suggested (setting the editor or using the CreationFilter), you can't set the FilterOperandStyle to Edit. Once you do that, it doesn't work and you get the original problem. So you should leave that set to Default and then use one of the other approaches I mentioned to remove the dropdown button.
Ok, thank you for your answers. EditorWithCombo seems to be our best solution. I'll discuss this with our team.
I expect you have probably moved on from this, but we have looked into the issue more deeply and the underlying cause is extremely complex and so the developers have decided it would be too dangerous to "fix" it in the control.
However, I have discovered that one root of the problem is that when you use FilterOperandStyle.Edit, the filter cell converts what you type to the DataType of the column. So the filter condition is looking for a Numeric zero instead of a string zero. And then the filter itself ends up running that value through the ValueList and looking for the wrong test entirely.
The practical implications of that is that there's another potential workaround. If, for some reason, you don't like the other workarounds I gave you and you really want to set the FilterOperandStyle.Edit, you can still make the filter work correctly by forcing the filter conditions for the column to always use a string.
private void UltraGrid1_BeforeRowFilterChanged(object sender, BeforeRowFilterChangedEventArgs e)
if (e.NewColumnFilter.Column.Key == "Int32 1")
foreach (FilterCondition filterCondition in e.NewColumnFilter.FilterConditions)
if (!(filterCondition.CompareValue is string))
filterCondition.CompareValue = filterCondition.CompareValue.ToString();
Thank you for the tip, Mike.
We haven't moved on with this issue. It's currently on hold. So, we are open to ideas and fixes from your side.
Unfortunately, the fix above didn't solve all the cases.
"0" => Solved
Any integer value that doesn't start with 0 => Solved
"0X" where X is an integer => filter key is resolved to X, and the filtering is executed with the query "contains 'X'" instead of "contains '0X'".
Unfortunately, we have many clients that use record labels in the form of "0X:YZ abc" where XYZ are all integers.