楼主你这个例子为什么没有分页是因为 你的store没有load 在你的store定义完之后要load 比如:
store.load({params:{start:0,pageSize:20}}) 在给你一个json从后台获取的例子:
var store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url :MAIN_SERVLET,
method : 'GET'
}),
reader : new Ext.data.JsonReader({
root : 'topics',
totalProperty: 'totalCount',
id : 'uids'
},[
{name : 'uids',type : 'string'},
{name : 'pid', type : 'string'},
{name : 'warnrulename', type : 'string'},
{name : 'sourcedatatable',type : 'string'},
{name : 'sourcedataitem', type : 'string'},
{name : 'comdatatable', type : 'string'},
{name : 'comdataitem', type : 'string'},
{name : 'calculatetype', type : 'string'},
{name : 'rangemin', type : 'float' },
{name : 'rangemax', type : 'float'},
{name : 'warnlevel',type : 'string'},
{name : 'warnhelp', type : 'string'},
{name : 'moduleid', type : 'string'},
{name : 'sourcerelateitem', type : 'string'},
{name : 'sourcehidecon', type : 'string'},
{name : 'scalculatemode', type : 'string'},
{name : 'comrelateitem', type : 'string'},
{name : 'comhidecon', type : 'string'},
{name : 'comcalculatemode', type : 'string'},
{name : 'mid', type : 'string'}
]),
baseParams : {
ac : 'list',
bean : 'com.sgepit.pcmis.warn.hbm.PcWarnRules',
business :'baseMgm',
method :'findwhereorderby',
params : '1=1'
}
})
var selModel = new Ext.grid.CheckboxSelectionModel({
singleSelect :true,
header :'',
listeners : {
rowselect :function (sm,index,rec){
selectUids = rec.get('uids');
southStore.baseParams.params = "warnrulesid ='"+selectUids+"'";
southStoreReload();
rangeStore.baseParams.params = "warnrulesid='"+selectUids+"'";
rangeStoreReload();
},
rowdeselect : function (sm,index,rec){
selectUids = '';
southStore.baseParams.params = "warnrulesid ='"+selectUids+"'";
southStoreReload();
rangeStore.baseParams.params = "warnrulesid='"+selectUids+"'";
rangeStoreReload();
}
}
})
var columnModel = new Ext.grid.ColumnModel([selModel,
{
header : '主键',
dataIndex:'uids',
width:20,
hidden:true
},{
header : '规则名称',
width :120,
align : 'center',
dataIndex : 'warnrulename'
},{
header :'源数据表',
width : 60,
align : 'center',
dataIndex : 'sourcedatatable'
},{
header : '比较数据表',
width : 60,
align : 'center',
dataIndex : 'comdatatable',
renderer : function (value){
if(value=='null'){
return "";
}else {
return value;
}
}
},{
header : '范围最小值',
width : 0,
hidden : true,
align : 'right',
dataIndex : 'rangemin'
},{
header : '范围最大值',
width : 0,
hidden : true,
align : 'right',
dataIndex : 'rangemax'
},{
header : '预警内容说明',
width : 0,
hidden : true,
dataIndex : 'warnhelp'
}
]);
var grid = new Ext.grid.GridPanel({
title : '预警规则定义列表',
id : 'north-grid',
region : 'north',
height : 300,
width :1050,
store: store,
sm :selModel,
cm: columnModel,
iconCls: 'icon-show-all',
border: false,
layout: 'fit',
header: true,
autoScroll: true, //自动出现滚动条
collapsible: false, //是否可折叠
animCollapse: false, //折叠时显示动画
loadMask: true, //加载时是否显示进度
trackMouseOver:true,
viewConfig: {
forceFit: true,
ignoreAdd: true
},
tbar:[
{text: '新增',
iconCls:'add',
handler:opWin},'-',{
text :'修改',
iconCls : 'select',
handler :modifyfunction
},'-',{
text : '删除',
iconCls : 'remove',
handler : removeRules
},'-',{
text : '分配责任人',
iconCls : 'option',
handler : distributePerson
}
],
bbar: new Ext.PagingToolbar({//在底部工具栏上添加分页导航
pageSize: PAGE_SIZE,
store: store,
displayInfo: true,
displayMsg: ' {0} - {1} / {2}',
emptyMsg: "无记录。"
})
});
northReload();
function northReload(){
store.load({params:{start : 0,limit : PAGE_SIZE}});
}
store.load({params:{start:0,pageSize:20}}) 在给你一个json从后台获取的例子:
var store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url :MAIN_SERVLET,
method : 'GET'
}),
reader : new Ext.data.JsonReader({
root : 'topics',
totalProperty: 'totalCount',
id : 'uids'
},[
{name : 'uids',type : 'string'},
{name : 'pid', type : 'string'},
{name : 'warnrulename', type : 'string'},
{name : 'sourcedatatable',type : 'string'},
{name : 'sourcedataitem', type : 'string'},
{name : 'comdatatable', type : 'string'},
{name : 'comdataitem', type : 'string'},
{name : 'calculatetype', type : 'string'},
{name : 'rangemin', type : 'float' },
{name : 'rangemax', type : 'float'},
{name : 'warnlevel',type : 'string'},
{name : 'warnhelp', type : 'string'},
{name : 'moduleid', type : 'string'},
{name : 'sourcerelateitem', type : 'string'},
{name : 'sourcehidecon', type : 'string'},
{name : 'scalculatemode', type : 'string'},
{name : 'comrelateitem', type : 'string'},
{name : 'comhidecon', type : 'string'},
{name : 'comcalculatemode', type : 'string'},
{name : 'mid', type : 'string'}
]),
baseParams : {
ac : 'list',
bean : 'com.sgepit.pcmis.warn.hbm.PcWarnRules',
business :'baseMgm',
method :'findwhereorderby',
params : '1=1'
}
})
var selModel = new Ext.grid.CheckboxSelectionModel({
singleSelect :true,
header :'',
listeners : {
rowselect :function (sm,index,rec){
selectUids = rec.get('uids');
southStore.baseParams.params = "warnrulesid ='"+selectUids+"'";
southStoreReload();
rangeStore.baseParams.params = "warnrulesid='"+selectUids+"'";
rangeStoreReload();
},
rowdeselect : function (sm,index,rec){
selectUids = '';
southStore.baseParams.params = "warnrulesid ='"+selectUids+"'";
southStoreReload();
rangeStore.baseParams.params = "warnrulesid='"+selectUids+"'";
rangeStoreReload();
}
}
})
var columnModel = new Ext.grid.ColumnModel([selModel,
{
header : '主键',
dataIndex:'uids',
width:20,
hidden:true
},{
header : '规则名称',
width :120,
align : 'center',
dataIndex : 'warnrulename'
},{
header :'源数据表',
width : 60,
align : 'center',
dataIndex : 'sourcedatatable'
},{
header : '比较数据表',
width : 60,
align : 'center',
dataIndex : 'comdatatable',
renderer : function (value){
if(value=='null'){
return "";
}else {
return value;
}
}
},{
header : '范围最小值',
width : 0,
hidden : true,
align : 'right',
dataIndex : 'rangemin'
},{
header : '范围最大值',
width : 0,
hidden : true,
align : 'right',
dataIndex : 'rangemax'
},{
header : '预警内容说明',
width : 0,
hidden : true,
dataIndex : 'warnhelp'
}
]);
var grid = new Ext.grid.GridPanel({
title : '预警规则定义列表',
id : 'north-grid',
region : 'north',
height : 300,
width :1050,
store: store,
sm :selModel,
cm: columnModel,
iconCls: 'icon-show-all',
border: false,
layout: 'fit',
header: true,
autoScroll: true, //自动出现滚动条
collapsible: false, //是否可折叠
animCollapse: false, //折叠时显示动画
loadMask: true, //加载时是否显示进度
trackMouseOver:true,
viewConfig: {
forceFit: true,
ignoreAdd: true
},
tbar:[
{text: '新增',
iconCls:'add',
handler:opWin},'-',{
text :'修改',
iconCls : 'select',
handler :modifyfunction
},'-',{
text : '删除',
iconCls : 'remove',
handler : removeRules
},'-',{
text : '分配责任人',
iconCls : 'option',
handler : distributePerson
}
],
bbar: new Ext.PagingToolbar({//在底部工具栏上添加分页导航
pageSize: PAGE_SIZE,
store: store,
displayInfo: true,
displayMsg: ' {0} - {1} / {2}',
emptyMsg: "无记录。"
})
});
northReload();
function northReload(){
store.load({params:{start : 0,limit : PAGE_SIZE}});
}
解决方案 »
- 这里多少人用notepad++??
- 父iframe跳转到嵌套子iframe
- 求教:一个JS函数问题
- |zyciis| 如何点击了里面的div的onclick不执行外面div的click 有代码,谢谢
- style为空或不是对象
- 怎样在用JS修改HTML中加载的XML文件名称?
- 用JS+XML+HTML做的随机测试生成,可是试题显示不出来,实在找不到错误,憋死我了
- 不知怎么做
- 我想在HTML里调用外部JS文件,如何调用?
- 关于DIV 的DRAG,DRAG时鼠标的形态如何控制?我这里不知怎么的是一个DISABLED的图标。
- 关于【手机】浏览器滚动条是否到达底部的问题
- 怎么查找一个字符串中某个字符出现的所有位置
我的是ArrayReader,网上合偶尔看到些资料说不支持分页。不知是否这样,有没有ArrayReader这方面的例子。