Ticket T1285984
Visible to All Users

Grid - Numeric column - Contains

created 6 days ago

Hi

The autoFilterRow supports search by value or DisplayText.
I would like to use Contains in a numeric column and specify ColumnFilteMode = "DisplayText"

It works almost :)
I would prefer to search without thousand separators, so the user can write in the filter 123 and get rows like 451,234.00

I cannot see a way to do this.
I need a custom contains operator.

Can you help?

Flemming

Answers approved by DevExpress Support

created 6 days ago

Hello Flemming,

Thank you for the description.

When you enable filtering values by their display text, the entire text is taken into account and there are no built-in options to ignore decimal or thousands separators. Therefore, the only way to support this behavior is to implement it manually. This can always lead to side effects. The simplest way to support this functionality is to use CellTemplates to show thousand and decimal separators, while EditSettings use settings with a format without such separators. EditSettings affect filtering, while CellTemplates only determine how cells should represent their values. Here is a possible implementation:

XAML
<dxg:GridColumn FieldName="SomeValue" ColumnFilterMode="DisplayText" AutoFilterCriteria="Contains"> <dxg:GridColumn.EditSettings> <dxe:TextEditSettings DisplayFormat="#########.00"/> </dxg:GridColumn.EditSettings> <dxg:GridColumn.CellTemplate> <DataTemplate> <dxe:TextEdit Mask="###,###,###.00" MaskType="Numeric" MaskUseAsDisplayFormat="True" x:Name="PART_Editor"/> </DataTemplate> </dxg:GridColumn.CellTemplate> </dxg:GridColumn>

As I said, there are side effects in such solutions. The filter popup will also show values without separators. Moreover, end users won't be able to find a value if they enter text with the thousand separators in the auto filter row.

Please try this implementation in your real application and let me know if it is suitable.

Regards,
Andrey

    Comments (2)
    Flemming Østergaard 6 days ago

      Hello Andy

      Thanks – it does solve the problem.
      I can see the sideeffect with filterpopup display, but think it is OK.

      But would it not be a better, more flexible way if you made it possible to override the Contains operator (and other)

      But thanks for the help.

      Med Venlig Hilsen / Best regards
      Flemming Østergaard

      Kirill (DevExpress Support) 5 days ago

        Hello,

        Technically, you can replace any filtering operator with a custom operator when it's used in the GridControl filtering mechanism. To do this, you can handle SubstituteFilter and use the helper classes demonstrated in the following KB article: Traverse Through and Modify the CriteriaOperator Instances. I also recommend you refer to these help topics about how you can create a custom function operator:

        Thanks,
        Kirill

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.