JSP页面使用Ext中Grid实现显示和分页时无法显示的问题?
页面初加载时需显示数据,不知道是哪里出错了.求高手改代码或给能用的新代码(要求:能结合Struts,分页,Oracle)控制层代码:HttpServletRequestr...
页面初加载时需显示数据,不知道是哪里出错了.
求高手改代码或给能用的新代码(要求:能结合Struts,分页,Oracle)
控制层代码:
HttpServletRequest request = ServletActionContext.getRequest();
int index = 1;
int pageSize = 10;
List list = new ArrayList();
for (int i = index; i < pageSize + index; i++) {
Grid bean1 = new Grid();
bean1.setId(String.valueOf(i));
bean1.setName("name" + i);
bean1.setDescn("descn" + i);
list.add(bean1);
}
int totalSize= 16;
ListRange<FlowType> regionAreaListRange = new ListRange<FlowType>();
regionAreaListRange.setList(list);
regionAreaListRange.setMessage("list");
regionAreaListRange.setTotalSize(totalSize);
regionAreaListRange.setSuccess(true);
JsonConfig config = new JsonConfig();
config.registerJsonValueProcessor(Date.class,
new DateJsonValueProcessor("yyyy-MM-dd"));
ServletActionContext.getResponse().setContentType(
"text/javascript;charset=UTF-8");
PrintWriter out = ServletActionContext.getResponse().getWriter();
String tmp = JSONObject.fromObject(regionAreaListRange).toString();
out.write(tmp);
页面JS代码:
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([{
header: '编号',
dataIndex: 'id'
}, {
header: '名称',
dataIndex: 'name'
}, {
header: '描述',
dataIndex: 'descn'
}]);
var store = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(date),
reader: new Ext.data.ArrayReader({
}, [{
name: 'id'
}, {
name: 'name'
}, {
name: 'descn'
}])
});
var ds = new Ext.data.Store({
reader : new Ext.data.JsonReader({
root : "list",
totalProperty : 'totalSize',
remoteSort:true,
fields : ['id','name', 'descn']
}),
proxy : new Ext.data.HttpProxy({
url : webAppPath
+ '/selfserv/logmanager/goLoginAction.action'
})
});
var grid = new Ext.grid.GridPanel({
el: 'grid',
ds: ds,
cm: cm,
width: 550,
autoHeight:true,
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
ds.load({
params: {
start: 0,
limit: 10
}
});
grid.render();
}); 展开
求高手改代码或给能用的新代码(要求:能结合Struts,分页,Oracle)
控制层代码:
HttpServletRequest request = ServletActionContext.getRequest();
int index = 1;
int pageSize = 10;
List list = new ArrayList();
for (int i = index; i < pageSize + index; i++) {
Grid bean1 = new Grid();
bean1.setId(String.valueOf(i));
bean1.setName("name" + i);
bean1.setDescn("descn" + i);
list.add(bean1);
}
int totalSize= 16;
ListRange<FlowType> regionAreaListRange = new ListRange<FlowType>();
regionAreaListRange.setList(list);
regionAreaListRange.setMessage("list");
regionAreaListRange.setTotalSize(totalSize);
regionAreaListRange.setSuccess(true);
JsonConfig config = new JsonConfig();
config.registerJsonValueProcessor(Date.class,
new DateJsonValueProcessor("yyyy-MM-dd"));
ServletActionContext.getResponse().setContentType(
"text/javascript;charset=UTF-8");
PrintWriter out = ServletActionContext.getResponse().getWriter();
String tmp = JSONObject.fromObject(regionAreaListRange).toString();
out.write(tmp);
页面JS代码:
Ext.onReady(function(){
var cm = new Ext.grid.ColumnModel([{
header: '编号',
dataIndex: 'id'
}, {
header: '名称',
dataIndex: 'name'
}, {
header: '描述',
dataIndex: 'descn'
}]);
var store = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(date),
reader: new Ext.data.ArrayReader({
}, [{
name: 'id'
}, {
name: 'name'
}, {
name: 'descn'
}])
});
var ds = new Ext.data.Store({
reader : new Ext.data.JsonReader({
root : "list",
totalProperty : 'totalSize',
remoteSort:true,
fields : ['id','name', 'descn']
}),
proxy : new Ext.data.HttpProxy({
url : webAppPath
+ '/selfserv/logmanager/goLoginAction.action'
})
});
var grid = new Ext.grid.GridPanel({
el: 'grid',
ds: ds,
cm: cm,
width: 550,
autoHeight:true,
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
ds.load({
params: {
start: 0,
limit: 10
}
});
grid.render();
}); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询