DHTMLX Docs & Samples Explorer

Sorting

Items can be sorted by any properties. Default sorting process values as strings, case insensitive.

//sort all data by Maintainer property in ascedent order
    view.sort("#Maintainer#","asc"); 
//same but in descedent order
    view.sort("#Maintainer#","desc");

If you need a custom sorting rule you can define your own sorter function

    view.sort(function(objA, objB){
         //objA and objB - are objects which need to be compared
         return objA.some_value > objB.some_value?1:-1;
    },"asc");

Custom sorting method accepts two object and must return 1 if first object is greater than second one, or -1 otherwise.

Direction parameter

  • “asc” - ascedent order, case insensitive
  • any other value - descedent order