extjs 包含空值时排序的小问题

 尽管在列模式表格中设置了排序为true,但是当此列值中有空值的话,点击排序不准确。

 

 var store = new Ext.data.Store({ 
    proxy: new Ext.data.HttpProxy({
            url:'userlevel' ,
            scripts:true 
       }),  
     reader: new Ext.data.JsonReader({
    totalProperty: 'rowCount',
    root: 'root', 
fields: [{'userlevel'} ]
           })  
     }); 

 

 var cm = new Ext.grid.ColumnModel([

        new Ext.grid.RowNumberer(),//显示行号
        {header:'积分',dataIndex:'userlevel',sortable:true,width:80,renderer:renderNull},
 
 
 
据说ext内部排序是按照ASCII来的...俺米有看过源码....还处于初步接触ext的状态....
 
解决办法:
 var store = new Ext.data.Store({ 
    proxy: new Ext.data.HttpProxy({
            url:'userlevel' ,
            scripts:true 
       }),  
     reader: new Ext.data.JsonReader({
    totalProperty: 'rowCount',
    root: 'root', 
fields: [{name:'userlevel',type:'string'} ]
           })  
     }); 
 
 
将fields中的参数指定type(数据类型)。
 
API中的值是:
type : String
(Optional) The data type for conver...
(Optional) The data type for conversion to displayable value. Possible values are
  • auto (Default, implies no conversion)
  • string
  • int
  • float
  • boolean
  • date
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值