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
460
GridView example of sorting multiple columns in C#
posted

Hi 

I'd like to get an example of sorting multiple columns in a grid using C#.  

Thanks

Kathy

Parents
  • 40030
    Offline posted

    Hi Kathy, 

    Sure, i'd be happy to help. 

    Assuming you're using an IGGridViewDataSourceHelper,  you just need to create IGGridViewSortedColumn objects and assign them to your IGGridViewDataSourceHelper. like this:

    dsh.SortedColumns.AddObjects(new NSObject[]{new IGGridViewSortedColumn ("firstName", IGGridViewSortedColumnDirection.IGGridViewSortedColumnDirectionAscending), new IGGridViewSortedColumn ("lastName", IGGridViewSortedColumnDirection.IGGridViewSortedColumnDirectionAscending)});

    In the code above, all i'm doing is creating 2 new sorted column objects. The first is my firstName property and the second is my lastName property. The order you assign to the SortedColumns collection determines the order the sort is applied. So in this case firstName is sorted first and then lastName is a sub sort applied to objects that have the same firstName.

    You can read more about this feature here:

    http://help.infragistics.com/iOS/2013.2/?page=IGGridView_Sorting_Columns.html

    And, if you're interested in learning how sorting in objective-c actually works, I wrote a blog on it not long ago. 

    http://es.infragistics.com/community/blogs/stevez/archive/2013/10/16/ios-objective-c-sorting-an-array.aspx

    Hope this helps,

    -SteveZ



Reply Children