sort

sorts controls according to some criteria

void sort(object by,function rule);

Parameters

byobjectthe parameters for sorting
rulefunctiona sorting rule; the function must have two parameters and return a number (-1,0,1)

Example

toolbar.data.sort({by:"type", dir:"desc"});

Details

The by object has the following parameters:

  • by - ( string) the field of the item object
  • dir - (string) the direction of sorting ('asc' or 'desc')

For more complex sorting, set these parameters:

toolbar.data.sort({
    rule: (a,b) => (a.type < b.type) ? -1 : ( (a.type > b.type) ? 1 : 0 )
});
Back to top