2 Replies Latest reply on Jun 23, 2009 9:16 AM by kolban1

    Creating a reusable datagrid sortCompareFunction

    kolban1 Level 1


      I was looking at writing a re-usable sortCompareFunction for use with DataGrids but I think I am missing something obvious.  A sort compare function has a signature that looks like:


      function mySort(obj1: Object, obj2: Object): int


      Now assume that the Data for the grid contains Objects that have fields "A", "B" and "C".


      When the mySort() function is called to sort data, it doesn't seem that I know which column/field in the data the sort should be applied to.  It would appear that I would have to write three sort functions, one for "A", one for "B" and one for "C" and define each of these for the sortCompareFunction for the corresponding column.  But in my solution I can't do this as I have a dynamic/variable number of columns and don't know ahead of time the field name in the object that I need to sort upon.