EasyUI datagird 排序 按數字類型的問題


easyui datagird 默認顯示的數據都是字符, 對要數字列進行排序規則,需要自定義排序規則
如果按字符排序 27竟然小於4 這不是我們想要的。
解決方案
<table id='grid'class='easyui-datagrid' style='width:1100px;height:430px' 
       url='Ajax-index.php?module=<{$module_name}>&action=Ajax_ReportView_Agent_Call_Report_Select&assigned_user_id=<{$assigned_user_id}>'  
      title='列表' iconCls='icon-table'  rownumbers='true' fitColumns='true' singleSelect='true' toolbar='#toolbar'  remoteSort='false'>  
</table>

<script type='text/javascript'> //按數字類型排序 自定義排序 function sort_int(a,b){ if(a.length > b.length) return 1; else if(a.length < b.length) return -1; else if(a > b) return 1; else return -1; }
//顯示列 $(
'#grid').datagrid({ columns: [[ {field:'user_name',title:'坐席工號',width:20,align:'center'}, {field:'first_name',title:'坐席員',width:20,align:'center'}, {field:'call_count',title:'電話總量',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'callout_count',title:'呼出數量',width:20,align:'center' , sortable:true,sorter:sort_int}, {field:'callin_count',title:'呼入數量',width:20,align:'center', sortable:true,sorter:sort_int }, {field:'callout_time_len',title:'呼出總時長(秒)',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'callin_time_len',title:'呼入總時長(秒)',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'talk_time_len',title:'通話總時長(秒',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'avg_talk_len',title:'平均通話時長(秒)',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'talk_count',title:'接通總量',width:20,align:'center', sortable:true,sorter:sort_int}, {field:'talk_ratio',title:'接通率',width:20,align:'center'} ]] }); </script>

 


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM