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?
Hello Burak,
I don't see a reason why this wouldn't work. Which version of Infragistics are you using? It's possible that what your seeing is a bug.
We are using 15.2 and 18.2. We see the same behavior on both versions.
I tied this out (in 18.2) and it works fine for me.
I am attaching my sample here so you can try it out and see if you get different results. If so, then there must be something different in your real application that is causing the problem.
One difference I noticed is that the tooltip for the filter cell in my sample says "Contains '08'" and not "Contains 8". So my best guess is that you are doing something that is causing the filter cell to store the wrong value - maybe you are handling Before/AfterCellUpdate or Before/AfterRowFilterChanged and somehow modifying the filter condition so that it contains a numeric value instead of the text the user typed in.
If that's not the case, then I can't immediately think of anything that might cause this to happen, but I am making some assumptions in my sample, so maybe you can verify if those are the same in your real app:
1) The column's DataType in my sample is Int32.
2) I am using 'Contains' as the filter operator.
3) The ValueList uses Int32 for the DataValue of each item (which matches the column's data type).
4) I am using FilterUIType.FilterRow.
WindowsFormsApplication49.zip
Thank you for your answer, Mike.
The line below caused the unwanted behavior.
ultraGrid.DisplayLayout.Override.FilterOperandStyle = FilterOperandStyle.Edit;
I commented it out and now it's ok, but I have another problem. Now, I see a dropdown when I activate the filter cell.
I need the previous behavior of a simple ultragridcell without a dropdown. Do you have any idea how I can achieve this?
Hm, that's odd. I'm not sure why switching the FilterOperandStyle to Edit causes a change in the filtering behavior. that seems like it might be a bug.
FilterOperandStyle basically changes the editor user by the filter cell from an EditorWithCombo (which is the default) to an EditorWithText. So just as a test, I tried assigning an EditorWithCombo to each cell in the filter row and I turned off the DropDown button in the editor. So I did this at the bottom of the InitializeLayout event.
var editorWithCombo = new EditorWithCombo(); editorWithCombo.ButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Never; foreach (var filterCell in layout.Rows.FilterRow.Cells) { filterCell.Editor = editorWithCombo; }
This seems to work, but as I said, I'm not really sure why the problem is occurring in the first place or exactly why this fixes it.
Another potential option would be to leave the Editor alone and use a CreationFilter to remove the dropdown button UIElement in each Filter cell. That's a little more complicated, but it's probably safer. The CreationFilter class would look something like this.
internal class NoDropDownButtonInFilterCellsCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { if (parent is EditorWithComboUIElement) { var cell = parent.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell == null || false == cell.IsFilterRowCell) { return; } var editorWithTextUIElement = parent.GetDescendant(typeof(EditorWithTextUIElement)); var editorWithComboDropDownButtonUIElement = parent.GetDescendant(typeof(EditorWithComboDropDownButtonUIElement)); if (null == editorWithTextUIElement || null == editorWithComboDropDownButtonUIElement) { return; } editorWithTextUIElement.Rect = parent.RectInsideBorders; // We could remove this element, but it's probably safer just to give it // an empty rect so the user can't click on it. editorWithComboDropDownButtonUIElement.Rect = Rectangle.Empty; } } public bool BeforeCreateChildElements(UIElement parent) { // Do nothing return false; } }
And you hook it up to the grid like so:
this.ultraGrid1.CreationFilter = new NoDropDownButtonInFilterCellsCreationFilter();
Frankly, though... I'm not sure why you want to remove the dropdown entirely. Why not left the user choose a value from the list in the filter cell? I can see how it might not make sense to have things like Custom or Blanks on there, but you can easily remove those using the FitlerDropDownItems property.