onBeforeSort

fires before sorting of the dataset

boolean onBeforeSort(string/function/undefined by,string/undefined dir,string/function as);
bystring/function/undefinedthe template of the sort-by field
dirstring/undefinedthe direction of sorting
asstring/functionthe type of sorting
booleanreturning false will prevent sorting

Example

view.data.attachEvent("onBeforeSort", function(by, dir, as){
    //... some code here ...
});

Details

Returning false from the event handler will block further processing, and data will not be sorted.

If the third param is a function, the parameters of such a function are the following:

  • a (object) - the first data item
  • b (object) - the second data item
  • prop(string) - the name of the field that the data will be sorted by.
table.sort("#fieldName#", "desc", function(a, b, prop) {
   return a[prop] - b[prop];
})
See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix javascript ui components library and page of javascript menu product.