这是显示部分
var store=new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: 'getUserData.jsp'
}),
//url:'http://design/getUserData.jsp',
reader: new Ext.data.JsonReader(
{fields:['username','usergroup']}
)
/* fields:[
{name:'username'},
{name:'usergroup'}]
*/
});
store.load();
var gridPanel=new Ext.grid.GridPanel({
store:store,
columns:[
/*{
header:'用户ID',
dataIndex:'id',
width:100
},*/
{
header:'用户名',
dataIndex:'username',
width:160
},{
header:'用户组',
dataIndex:'usergroup',
width:160
}],
viewConfig:{
sortAscText:'正序排列',
sortDescText:'逆序排列',
forceFit:true
},
width:600,
height:400,
frame:true,
//title:'Framed with Checkbox Selection and Horizontal Scrolling',
iconCls:'icon-grid'
});
下面是数据,读取的页面的内容没有html,head和body标签,只有
[
{"username":"aaa","usergroup":"bbb"},
{"username":"bbb","usergroup":"111"}
]
我试过直接在store用data属性直接给值,显示正常,但是一旦到网页去取,就取不到值
现在死活拿不到值,试过很多方法了
JsonStore 里面 与三个属性就足够了 fields url root 后台返回的应该是一个json对象 如果你的root属性为 root:'root' 那么返回的json就应该是 {root:[attr1:value,attr2:value]}
fields 是一个数组 里面是属性的名字 具体可以查看api 里面说的很清除
[size=xx-large]你的JsonStore中提供了url,缺没有提供method,你写个method=post试试!这可能是ext 的一个bug吧!另外建议你在加点其他的配置属性,[/size]
autoLoad:false
,autoDestroy:true
,remoteSort:true
,root:'rows'
,totalProperty:'total'
,idProperty:'ID',
[size=xx-large]ext就是这样的毛病,有时候少写一个配置,累死都找不出错误[/size]