问题描述
varstore=Ext.create('Ext.data.TreeStore',{id:"treestore",proxy:{type:'ajax',url:'test.dt',reader:{type:'json',root:'info'}},root:{expanded:true}});Ext.create('Ext.tree.Panel',{title:'SimpleTree',width:200,height:150,store:store,id:"treePanel",rootVisible:true,renderTo:Ext.getBody(),listeners:{beforerender:function(){},load:function(store,operation,options){}}});json数据为{"success":true,"info":{"id":"id1","text":"AAAAAAA","expand":true,"info":[{"id":"id2","text":"BBBBBB"}]}}我把reader里面的root改为info.info就不显示,不知道什什么原因?
解决方案
解决方案二:
root改为info显示吗
解决方案三:
可以,会把info.info里面的数据也加载上去。引用1楼zhuni_xingfu的回复:
root改为info显示吗
解决方案四:
可能是因为info.info里面是数组不是json对象
解决方案五:
如果只用到info.info里面的数据,其他数据又不能去掉,该如何写呢?引用3楼langjian305的回复:
可能是因为info.info里面是数组不是json对象
解决方案六:
上次搞错啦给store的值貌似就该是数组你那样应该可以的啊root:"info.info"
解决方案七:
关键就是不行,不知道什么原因,浏览器显示说info不能读。引用5楼langjian305的回复:
上次搞错啦给store的值貌似就该是数组你那样应该可以的啊root:"info.info"
解决方案八:
这就怪了我今天还特意试了一下我这边可以的root可以用对象.属性的还可以数组xxx[i]的形式或者xxx[i].属性我都试了store都能取到值不知道你这边什么情况但是如果实在不行那你就root:"info"吧然后再对这个store里面的值操作一下
解决方案九:
能不能把你的代码和json数据发来看看?引用7楼langjian305的回复:
这就怪了我今天还特意试了一下我这边可以的root可以用对象.属性的还可以数组xxx[i]的形式或者xxx[i].属性我都试了store都能取到值不知道你这边什么情况但是如果实在不行那你就root:"info"吧然后再对这个store里面的值操作一下
解决方案十:
代码在公司电脑明日发你
解决方案十一:
先谢谢了,这个问题困扰我好几天了。引用9楼langjian305的回复:
代码在公司电脑明日发你
解决方案十二:
varmyQuestionStore=Ext.create("Ext.data.Store",{model:'questionModel',pageSize:10,proxy:newExt.data.HttpProxy({type:"ajax",url:securedwebroot+'question/query',extraParams:{type:'',categoryId:'',createtimeStart:'',createtimeEnd:'',keyword:''},reader:{type:'json',root:'records[0].choice',totalProperty:'reason'}})});myQuestionStore.on('load',function(){alert(Ext.encode(myQuestionStore.getAt(0).data));});这个是json数据{"reason":"30","success":true,"records":[{"categoryId":2,"createUser":"新世基操作员D","createTimeStart":null,"createTimeEnd":null,"lastModifyUser":"新世基正管理者","createTime":"2011-09-2814:26:37","lastModifyTime":"2011-10-2609:47:27","selectedCount":0,"categoryName":null,"choice":[{"type":10,"version":44,"sequence":1,"orgId":1,"name":"2","id":273},{"type":10,"version":44,"sequence":2,"orgId":1,"name":"3","id":274},{"type":20,"version":22,"sequence":6,"orgId":1,"name":"13","id":689},{"type":10,"version":43,"sequence":3,"orgId":null,"name":"hhh","id":729},{"type":10,"version":43,"sequence":4,"orgId":null,"name":"ff","id":730},{"type":10,"version":43,"sequence":5,"orgId":null,"name":"45","id":731}],"removedChoice":null,"type":10,"level":23,"version":44,"status":1,"orgId":1,"name":"4+3=?","id":277}数据比较多截了一点,,,下面是alert的store值:{"id":273,"type":10,"name":"2","level":"","choice":"","createUser":"","categoryId":"","createTime":"","lastModifyUser":"","lastModifyTime":"","isRequired":true}
解决方案十三:
这样他是可以得到数据的,只是得到的数据不能在树里面显示!你可以再写个树试试。引用11楼langjian305的回复:
varmyQuestionStore=Ext.create("Ext.data.Store",{model:'questionModel',pageSize:10,proxy:newExt.data.HttpProxy({type:"ajax",url:securedwebroot+'question/query',extraPa……
解决方案十四:
加我好友吧QQ:459738386treestore的好像要有text属性和children属性的