我的页面代码是:
var store1 = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url: 'InfohouseMgr.do'
}),
// set up the JsonReader
reader : new Ext.data.JsonReader({
root : 'taskList',
// totalProperty : 'totalSize'
},[
{name: 'ipaddress', type: 'string'},
{name: 'sendmobiles', type: 'string'},
{name: 'sendemail', type: 'string'}
])
});
store1.load();
var dis=new Ext.grid.ColumnModel([
{header:"IP地址",dataIndex:"ipaddress",sortable:true,align:"center"},
{header:"短信接收者",dataIndex:"sendmobiles",sortable:true,align:"center"},
{header:"邮件接收者",dataIndex:"sendemail",sortable:true,align:"center"}
]);
var grid = new Ext.grid.GridPanel({
renderTo:"hello",
title:"表格",
height:200,
width:600,
cm:dis,
store:store1,
autoExpandColumn:2
});
Action中的代码是:
Map map=new Hashtable();
map.put("success", true);
map.put("taskList", list);
JSONObject jsonMap = JSONObject.fromObject(map);
response.getWriter().write(jsonMap.toString());
System.out.println(jsonMap.toString());
request.setAttribute("json", jsonMap.toString());
我取到的list能成功的转换成json格式,但是页面上就是出不来。我想问一下大哥大姐一下,帮我看看错误,我都调了一天了,还没有出来,本人技术比较菜,谢谢了
这样就没问题了
[code="java"]
var store1 = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url: '/nms/infohouse/middle.jsp'
}),
// set up the JsonReader
reader : new Ext.data.JsonReader({
root : 'taskList',
totalProperty : 'totalSize'
},[
{name: 'ipaddress', type: 'string'},
{name: 'sendmobiles', type: 'string'},
{name: 'sendemail', type: 'string'}
])
});
store1.load();
var dis=new Ext.grid.ColumnModel([
{header:"IP地址",dataIndex:"ipaddress",sortable:true,align:"center"},
{id:"sendmobiles",header:"短信接收者",dataIndex:"sendmobiles",sortable:true,align:"center"},
{header:"邮件接收者",dataIndex:"sendemail",sortable:true,align:"center"}
]);
var grid = new Ext.grid.GridPanel({
renderTo:"hello",
title:"表格",
height:200,
width:600,
cm:dis,
store:store1,
autoExpandColumn:"sendmobiles"//注意这里,这里只能是指定一列的id,不能用序号
});
[/code]
// totalProperty : 'totalSize'
这个也要用啊,
LZ参考这个
[url]http://itren.iteye.com/admin/blogs/255562[/url]
把你的json字符串,粘出来看,