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'}, 就是排序啊 为什么显示还是没有按照设定的显示呢? 很急 谢谢大伙了
{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'}, 就是排序啊 为什么显示还是没有按照设定的显示呢? 很急 谢谢大伙了
解决方案 »
- JPA用例出错
- 刚才看了一个关于字符串的问题,我又有了个新的问题~~~
- 基于ZK框架的开发应用,有人开发过吗?
- 关于tomcat5+jdk1.5.0+IIS 配置出错的问题 (Apache Jakarta Connector2)
- 求教spring security3.1怎样使用urlMactch
- 对这位大哥----Ryo_Hazuki(困了)----感激!!!
- 求一正则表达式, 判断金额的输入的(立刻给分)
- 请大家帮忙看看这个客户端调用ejb(bmp)出现的问题哈!整了一天了还是不知道怎么回事
- 怎么配置weblogic6.1 和jbuilder8
- 求助大神
- 关于java字段用eclipse自动生成get和set的方法的疑虑
- Spring与Hibernate整合getHibernateTemplate().delete(object)删除不了数据
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
}]
}),
[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"
}
]); 怎么加?
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 建议如果想要默认排序最好后台排序,如果只是数据出来了,想手工任意按某列排,可以用这个默认设置
ext会向后台传一个sort:按照什么排序,dir:asc or desc
你后台接收这个参数然后使用到sql语句里面即可。