I have been unable to get paging and sorting working with the built-in functions. The sort function only sorts the visible page and not all the data. I think it needs .allRows add.
My solution:
// Custom sort need for pagination
dg.datagrid({
onBeforeSortColumn: function(sort, order) {
var data = $(this).data('datagrid').allRows;
var opts = $(this).datagrid('getColumnOption', sort);
data.sort(function(a, b) {
// Call sort function?
if (typeof opts.sorter === 'function') {
if (order === "asc") {
return opts.sorter.call(this, a[sort], b[sort]);
}
return opts.sorter.call(this, b[sort], a[sort]);
}
});
$(this).datagrid('loadData', data);
// MUST return false to cancel easyUI sort
return false;
}
});
And I has to modify jquery.easyui.min.js
The datagrid-sort... class is before the call to onBeforeSortColumn
_645.find("div.datagrid-cell").removeClass("datagrid-sort-asc datagrid-sort-desc");
for(var i=0;i<_640.length;i++){
var col=_614(_63c,_640[i]);
_645.find("div."+col.cellClass).addClass("datagrid-sort-"+_641[i]);
}
if(opts.onBeforeSortColumn.call(_63c,_63f.sortName,_63f.sortOrder)==false){
return;
}
The only problem I have is I am unable to sort on treegrid children.
Please fix the sort and pagination in the EasyUI code.