Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1230
XamDataGrid v11.1 Custom FilterComparer not Firing
posted

We use the XamDataGrid quite extensively. We recently created our own user control that is used for a xml type data column in which we store multicurrency  field values. This meant that we had to basically create custom comparers for grouping, filtering, sorting etc. for this field type.

All the compares work except for FILTERING.

I have attached a sample application where I hooked a custom FilterComparer to field "Running Time".

You will notice that the comparer does not fire at all and keeps on using the default comparer.

This is again quite urgent to get this working as all our other comparers works 100%

WpfApplication1.zip
  • 30945
    Verified Answer
    Offline posted

    Hello,

    The reason for Comparer not to fire seems to be that you are using the filter operators for filtering string values ( StartsWith, Contains, EndsWith, …). The Compare method of the IComparer interface returns three values 1, 0 and -1 which corresponds to less than, equal and greater then. This values corresponds to the Equals, Not equals, Greater Than, Greater Then or equals to, Less then and Less then or equal to, so in order to use a FilterComparer you can use those filter operators.  You can set the default filter operator by setting the FilterOperatorDefaultValue property of the FieldSettings and you can specify the available operator by setting FilterOperatorDropDownItems. You can set those properties for a specific field as follows:

     

    In XAML:

    
    

     

            <igDP:Field Name="Running_x0020_Time" Label="Running Time">
                <igDP:Field.Settings>
                    <igDP:FieldSettings 
                FilterOperatorDefaultValue="Equals" 
                FilterOperatorDropDownItems="Equals, GreaterThan, LessThan, GreaterThanOrEqualsTo,  LessThanOrEqualsTo, NotEquals"
                FilterComparer="{Binding Source={StaticResource customFilterComparer}}"/>
                </igDP:Field.Settings>
            </igDP:Field>
    

     

    In C# code:

    
    

     

    this.xamDataGrid1.FieldLayouts[0].Fields[0].Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.GreaterThan
        | ComparisonOperatorFlags.GreaterThanOrEqualsTo
        | ComparisonOperatorFlags.LessThan
        | ComparisonOperatorFlags.LessThanOrEqualsTo
        | ComparisonOperatorFlags.NotEquals
        | ComparisonOperatorFlags.Top
        | ComparisonOperatorFlags.TopPercentile;
    

     

    If you need any further assistance please do not hesitate to ask.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support