EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on July 22, 2017, 04:02:34 AM



Title: Sorting Datalist
Post by: sky-t on July 22, 2017, 04:02:34 AM
Hi there,

how we can sort a Datalist?


Thanx


Title: Re: Sorting Datalist
Post by: stworthy on July 23, 2017, 01:05:09 AM
Set the column with 'sortable' property set to true.
Code:
$('#dl').datalist({
remoteSort: false,
columns : [[
     {field:'text',width:'100%',sortable:true,
      formatter:function(value,row,index){
      return value;
      }
     }
]]
})

And then you can call the 'sort' method to sort the data list.
Code:
$('#dl').datalist('sort',{sortName:'text',sortOrder:'asc'})
// or $('#dl').datalist('sort',{sortName:'text',sortOrder:'desc'})