EasyUI Forum

General Category => General Discussion => Topic started by: Kevin on September 02, 2019, 07:54:24 AM



Title: Sorting fire onLoadSuccess event
Post by: Kevin on September 02, 2019, 07:54:24 AM
Hi guys

Is there a reason why the onLoadSuccess event is fired whenever a column is clicked for sorting? Should this event only fire when the datagrid finishes loading data. After all there is the onSortColumn for this functionality. Is there a way to prevent this from happening?

Thanks


Title: Re: Sorting fire onLoadSuccess event
Post by: stworthy on September 03, 2019, 12:36:00 AM
The sorting action will cause the sorted data to be loaded again. This will trigger the 'onLoadSuccess' event. If you want to identify the sorting action, add a flag before sorting and remote it after loading data.
Code:
$('#dg').datagrid({
remoteSort: false,
onBeforeSortColumn: function(){
var opts = $(this).datagrid('options');
opts.isSorting = true;
},
onSortColumn: function(){
//...
},
onLoadSuccess: function(data){
var opts = $(this).datagrid('options');
opts.isSorting = false;
}
})


Title: Re: Sorting fire onLoadSuccess event
Post by: Kevin on September 03, 2019, 11:51:55 AM
That's works. Thanks very much stworthy. Your answers are always spot on.