-
22 Jan 2013 2:21 AM #1
Unanswered: Not able to view simple tree Grid with the local data
Unanswered: Not able to view simple tree Grid with the local data
Hi..please help me here..
I am trying to display a tree grid with hard coded data..I am not getting any errors and also not able to display any data.but store has all the data which is needed.. Please help me if i am going wrong any where
Thanks,Code:Ext.onReady(function() { Ext.create('Ext.tree.Panel', {title: 'Books', width: 500, height: 300, collapsible: true, useArrows: true, rootVisible: true, store: store, multiSelect: true, singleExpand: true, columns: [ { xtype: 'treecolumn', text: 'Object', flex: 2, sortable: true, dataIndex: 'object' }, { text: 'Name', flex: 1, dataIndex: 'name', sortable: true } , { text: 'Quantity', flex: 1, dataIndex: 'quantity', sortable: true } ], renderTo: Ext.getBody() }); }); var store=Ext.create('Ext.data.TreeStore', { storeId:'simpsonsStore', id:'storeName', autoLoad:true, fields:[{'type':'int','name':'id','mapping':'id'},{'name':'object','mapping':'object'}, {'name':'name','mapping':'name'},{ 'name':'quantity','mapping':'quantity'}],idProperty: 'id', data:{'record':[ { 'id':1,'object':'fruit','name': 'apple','quantity':'40','leaf':true,'parentId':1,'iconCls':'task-folder'}, { 'id':2,'object':'PC','name': 'HP','quantity':'2',iconCls:'task-folder','expanded':true , children: [ { 'id':21, 'object': "sand", 'name': "apple", 'quantity': "50 kg ", 'leaf': true, 'parentId':2 }, { 'id':22, 'object': "mud", 'name': "mango", 'quantity': "100 kg ", 'leaf': true, 'parentId':2 } ] }, {'id':3, 'object':'pen','name': 'cello','quantity':'30'}, ]}, proxy: { type: 'memory', reader: { type: 'json', root: 'record' } } });
Sandeep
-
24 Jan 2013 7:46 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
This is working for me using the root config:
Code:var store = Ext.create('Ext.data.TreeStore', { fields : [ 'id', 'object', 'name', 'quantity' ], root : { expanded : true, children : [ { id : 1, object : 'fruit', name : 'apple', quantity : '40', leaf : true, parentId : 1, iconCls : 'task-folder' }, { id : 2, object : 'PC', name : 'HP', quantity : '2', iconCls : 'task-folder', expanded : true, children : [ { id : 21, object : "sand", name : "apple", quantity : "50 kg ", leaf : true, parentId : 2 }, { id : 22, object : "mud", name : "mango", quantity : "100 kg ", leaf : true, parentId : 2 } ] }, { id : 3, object : 'pen', name : 'cello', quantity : '30' } ] } }); Ext.create('Ext.tree.Panel', { title : 'Books', width : 500, height : 300, collapsible : true, useArrows : true, rootVisible : true, store : store, multiSelect : true, singleExpand : true, columns : [ { xtype : 'treecolumn', text : 'Object', flex : 2, sortable : true, dataIndex : 'object' }, { text : 'Name', flex : 1, dataIndex : 'name', sortable : true } , { text : 'Quantity', flex : 1, dataIndex : 'quantity', sortable : true } ], renderTo : Ext.getBody() });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote