Hi,
I have a column with data type double. I have set inputMask ultraGrid1.DisplayLayout.Bands[0].Columns["Column1"].MaskInput = "####" so as not to see decimal places.
Also I set the value of the column = 33.33
Because I have inputMask what is see is 33.
In filter row if I open the dropdown list I can see the option 33 and if I type in the filter row 33 it shows me the row as expected.
The problem appears if I do not open the dropdown list. If I go to filter row and type 33, without having opened the dropdown, it shows me no results.
Could you please advice?
Thank you in advance
This is kind've an unusal thing to do - limiting the display to integers via a mask. I don't think that's really the intended use of masking.
I tried this out and I get the same results. I think what's happening here is that the dropdown list doesn't get populated until you drop it down the first time. Once it's populated, it contains a list of DisplayText (e.g. "33") and DataValue (e.g. 33.33) pairs. So once you drop it down and type "33" it recognizes the "33" on the list and matches it up to the 33.33 value and filters based on that value.
But before the list is populated, there's nothing to match up to and since "33" does not equal 33.33, it doesn't find anything and so there's no match.
So one potential solution would be to force the list to populate. But unfortunately, there's currently no way to do that.
So there are a number of approaches you could take.
The simplest thing to do, in my opinion would be to set the FilterOperatorDefaultValue on the column to Contains. That way, the filtering will match any cell whose value contains "33" anywhere within it's text. This assumes you are using the filter row.
Another, much more complex option, would be to handle the CellChange event of the grid, or maybe the BeforeRowFilterChanged event and watch for changes to the filter cell. Then you could try to take he filter that is applied and modify if to match the values in your actual grid column. But as I said, this would be very tricky and complex and would mean looping through all of the cells in the column manually and finding all of the potential values and matching them up yourself.
Another approach you could type, which is sort've a hybrid of the other two is you could handle the FilterRow event. This event fires any time the grid evaluates whether or not a row meets the filter criteria. So you could examine the value of the cell and the FilterConditons (which in this case would be Equals "33") and then decide if the row meets that criteria or not.
I attached my sample project here just for reference.
In my code I do not use mask. I use editor and I change the appearance in the editor. The result is that the text property of the grid column has different value from the value property. The use of mask was a simpler way to replicate my problem.
Whenever the text property is different than the value property the filter cell has the abovementioned behavior.
Is there any possibility that you could make any correction to this behavior?
Best Regards,
Greycon
I took another look into this and I don't think we can change this behavior. There's another property called FilterComparisonStyle (on the Override) which determined whether the filtering matches based on the DisplayText or the Value or both. But it does not apply to quantitative comparisons like Equals. Equals always works on an exact match of the Value and not the text.
So if you want different behavior, there are a number of ways you can achieve that. But we can't change the filtering behavior of the grid without breaking existing application for other customers.
You could change the FilterOperatorDefaultValue to Contains, as I suggested. Or if you don't want to do "Contains", then you could also use "Like" instead of Equals. The Like operator will match on "33", but not on "3" in this example.
Another option would be to handle the grid's FilterRow event and you can examine the filters and the row and decide for yourself whether the row meets the filter criteria yourself.