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
980
Custom Sorting
posted

Hi -

I have a grid that contains multiple field layouts that are represented by nested ObservableCollections.

A       Total of children

          50

          75

          10

B       Total of children

          -7

          -2

          -9

 

When I sort by the column, I want the rows in the nested collection to sort but I the top level collection (totals) to remain fixed. In addition, when I sort descending, the largest negative number should come first. When I sort that column descending, it should look like this:

A

        75

        50

        10

B

        -9

        -7

        -2

 

How would I go about this?

 

Thanks!

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello,

     

     I have been looking into the description of the functionality that you want and I am not sure I completely understand the first part of your question. Would you please give me more detailed description of the functionality that you are trying to achieve?

     

    About the second part of your question, this can be achieved by setting custom SortComparer for the field that you want to be sorted that way. I have created a sample application that demonstrates how you can set the SortComparer property of the FieldSettings for a given field. In order to achieve this sorting I created a class which implements IComparer interface and compare the values by their absolute values using the Math.Abs method.

     

    If you have any further questions please do not hesitate to ask.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    CustomSorting.zip
Children