var dictRecord = Ext.data.Record.create([
{name: 'dictName', type: 'string'},
{name: 'dictCode', type: 'string'},
{name: 'orderNum', type: 'int'},
{name: 'dictId', type: 'string'}
]);

// 获取动态数据
var proxy = new Ext.data.HttpProxy({
    url : "/SLaw/system/QueryFirstDict.action"
})

var store = new Ext.data.GroupingStore({
proxy: proxy,
remoteSort:true,
sortInfo: {field:'orderNum', direction:'ASC'},
reader: new Ext.data.JsonReader({
totalProperty: 'totalCount',
root: 'slawFirstDictList'
},dictRecord)
});

store.load({params:{start:0, limit:15}});
this.sm = new Ext.grid.CheckboxSelectionModel();
this.cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),// 获得行号
this.sm,//checkbox
{ header: "数据字典名称", width: 150, menuDisabled : true,
align: "center", sortable: true, dataIndex: "dictName"
},
{ header: "数据字典编码", width: 150, menuDisabled : true,
align: "center", sortable: true, dataIndex: "dictCode"
},
{ header: "显示顺序", width: 150,   menuDisabled : true,
align: "center", sortable: true, dataIndex: "orderNum"
},
{ menuDisabled : true, width: 150, hidden: true,
align: "center", sortable: true, dataIndex: "dictId"
}
]);关键的 sortInfo: {field:'orderNum', direction:'ASC'}, 就是排序啊 为什么显示还是没有按照设定的显示呢? 很急 谢谢大伙了

解决方案 »

  1.   

    试试这个:defaults : {
    sortable :true
    }如:
    cm :new Ext.grid.ColumnModel( {
    defaults : {
    sortable :true
    },
    columns : [new Ext.grid.RowNumberer(), sm,  {
    header :"抽查批次",
    dataIndex :'batchNo'
    },{
    header :"抽查范围类型",
    dataIndex :'surveyRange.name'
    },{
    header :"过滤条件",
    dataIndex :'filter',
    width:140
    }]
    }),
      

  2.   

    this.cm = new Ext.grid.ColumnModel(

    [new Ext.grid.RowNumberer(),// 获得行号
    this.sm,//checkbox
    { header: "数据字典名称", width: 150, menuDisabled : true,
    align: "center", dataIndex: "dictName"
    },
    { header: "数据字典编码", width: 150, menuDisabled : true,
    align: "center", dataIndex: "dictCode"
    },
    { header: "显示顺序", width: 150,   menuDisabled : true,
    align: "center", sortable: true, dataIndex: "orderNum"
    },
    { menuDisabled : true, width: 150, hidden: true,
    align: "center", dataIndex: "dictId"
    }
    ]); 怎么加?
      

  3.   

    个人认为:
            1 一般默认按某个字段排序,要在后台排好,比如后台返回list转换而来的json对象,list里面已经排好序了。
            2 如果要在页面排序也可以用 store的sort()方法,
                        如:store.sort(dictName);          可以查看一下api
           3  defaults : {sortable :true} 的用法就是放在
            cm :new Ext.grid.ColumnModel( {
              defaults : {
                   sortable :true
              },
           columns : [new Ext.grid.RowNumberer(),            其作用 不是默认排序,而是表示可按所有列排序,即数据已经出来了没有排序,点击某列列头(header)处,使数据按这列排序,默认升序。
            4 建议如果想要默认排序最好后台排序,如果只是数据出来了,想手工任意按某列排,可以用这个默认设置    
                 
      

  4.   

    后台排序加上sortable:true 点击某列会给后台传2个参数 一个是排序的字段名 一个是升降序
      

  5.   

    因为你的sql语句没有排序。
    ext会向后台传一个sort:按照什么排序,dir:asc or desc
    你后台接收这个参数然后使用到sql语句里面即可。