EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: varonica on September 10, 2014, 02:34:01 AM



Title: Sort column properties
Post by: varonica on September 10, 2014, 02:34:01 AM
I'm not sure if i miss it but all i want is to make datagrid sort(local sort) when data load successfully. Please help me guys!! :( :(


Title: Re: Sort column properties
Post by: Kevin on September 15, 2014, 04:56:03 PM
Sorting on the server is ideal. If you still need to sort the data, you can use the onLoadSuccess event. Then you could call the sort method. For example;
Code:
$('#dg').datagrid({
   onLoadSuccess: function(){
      $('#dg').datagrid('sort', {
         sortName: 'date',
         sortOrder: 'desc'
      });
   },
   fit: true,
   nowrap: true,
   striped: true,
   collapsible: true,
   columns: [[
      { field: 'date', title: 'Date', width: 120, sortable: true, sorter: function (a, b) { return (a > b ? 1 : -1); } },
      { field: 'name', title: 'Name', width: 120, sortable: true, sorter: function (a, b) { return (a > b ? 1 : -1); }}
  ]]
});