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>
复制代码

 


 

posted @   海乐学习  阅读(3826)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示