level 8
笨笨狸
楼主
写了一个基础的EXTJS程序,JSP从MYSQL取数后用JSON传递到EXTJS,但现在GRIDPANEL上始终显示不出数据,不知道什么原因?请教高手指点,谢谢。
JS代码如下:
Ext.onReady(function() {
var userStore = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
url : 'JSON/UserJSON.jsp'
}),
reader : new Ext.data.JsonReader({
totalProperty : 'results',
root : 'items',
id : 'userId',
record : 'userId'
}, new Ext.data.Record.create(['userId', 'userName'])),
fields : [{
name : 'userId'
}, {
name : 'userName'
}],
listeners : {
load : function() {
new Ext.Msg.alert('userStore记录数', userStore.getCount());
}
}
});
userStore.load();
var grid = new Ext.grid.GridPanel({
renderTo : Ext.getBody(),
store : userStore,
columns : [{
id : 'userId',
header : '用户ID',
sortable : true,
dataIndex : 'userId'
}, {
header : '用户名',
sortable : true,
dataIndex : 'userName'
}],
height : 500,
width : 600,
title : '家庭成员',
stateful : true,
stateId : 'grid'
});
});
后台JSP输出的JSON串如下:
json:{"items":[{"userId":100,"userName":"笨笨"},{"userId":101,"userName":"哈姆"},{"userId":102,"userName":"公用"}],"results":3}
2014年06月02日 05点06分
1
JS代码如下:
Ext.onReady(function() {
var userStore = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
url : 'JSON/UserJSON.jsp'
}),
reader : new Ext.data.JsonReader({
totalProperty : 'results',
root : 'items',
id : 'userId',
record : 'userId'
}, new Ext.data.Record.create(['userId', 'userName'])),
fields : [{
name : 'userId'
}, {
name : 'userName'
}],
listeners : {
load : function() {
new Ext.Msg.alert('userStore记录数', userStore.getCount());
}
}
});
userStore.load();
var grid = new Ext.grid.GridPanel({
renderTo : Ext.getBody(),
store : userStore,
columns : [{
id : 'userId',
header : '用户ID',
sortable : true,
dataIndex : 'userId'
}, {
header : '用户名',
sortable : true,
dataIndex : 'userName'
}],
height : 500,
width : 600,
title : '家庭成员',
stateful : true,
stateId : 'grid'
});
});
后台JSP输出的JSON串如下:
json:{"items":[{"userId":100,"userName":"笨笨"},{"userId":101,"userName":"哈姆"},{"userId":102,"userName":"公用"}],"results":3}