EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: joker on August 05, 2013, 03:04:38 AM



Title: Custom sort code
Post by: joker on August 05, 2013, 03:04:38 AM
Hi,
  When I Click column header with sortable feature , I hope it can execute my own code ,but not sort automatically,how can I do it.
  Thanks!


Title: Re: Custom sort code
Post by: stworthy on August 05, 2013, 06:09:43 AM
Use sorter function to define your custom sorting.
Code:
$('#dg').datagrid({
columns:[[
{field:'name',sorter:function(a,b){
//...
}}
]]
});


Title: Re: Custom sort code
Post by: joker on August 05, 2013, 06:55:39 PM
Maybe I don't describe my problem clearly.I want to implement Multiple Sorting,so when I click column header, I hope it don't sort automatically,I hope I can get column name and push it into array,then I can handle it in server side.But i don't know how to deal with it.I try to execute my code in onSortColumn event,but it can't stop datagrid sort automatically first,So what shall i do?


Title: Re: Custom sort code
Post by: stworthy on August 06, 2013, 04:44:50 PM
The multiple sorting is the build-in feature since version 1.3.4. If you are using version 1.3.3, download the datagrid plugin from http://www.jeasyui.com/easyui/plugins/jquery.datagrid.js and include it in your page.


Title: Re: Custom sort code
Post by: joker on August 06, 2013, 06:57:20 PM
Thanks for your reply。
But I still have a problem,How can I switch Multiple Sorting and Single Sorting in datagrid?


Title: Re: Custom sort code
Post by: stworthy on August 06, 2013, 08:25:38 PM
Here is the multiple sorting example.
http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Multiple%20Sorting