I need to sort data of a datatable. According to the value of one of the column data should be sorted and kept at the top. Data of another column has to considered for one more sort on the same table. Please check the Snippet.
You can use a custom sorting function to attune the datatable for the needed behaviour. As an example, check the following:
http://docs.webix.com/samples/15_datatable/02_sorting/02_custom.html
Also, the next sample show how data can be sorted by two columns ( as in your case ) by using a custom sorting function
http://docs.webix.com/samples/15_datatable/02_sorting/03_sort_api.html
@maksim
I have tried this custom sort function. This is being triggered at the click of button. But I need to trigger this function when a new row is added or deleted from the datatable. How can I achieve this? Where shall I keep this custom sort function so that it trigger when a new row is added or an existing row is removed.
I don’t think that you need to resort grid after row deleting, as it will never change the sorting order.
As for row adding you can use something like
grid.attachEvent("onAfterAdd", function(){
this.sort(custom_sorting_function);
});
@maksim
Thanks. I think this will help to some extend.
Suppose data of a row is edited by user, this happens to be the same column which I’m considering for sorting . Will this event get triggered after Edit?