PDA

View Full Version : Use of getNodeById() with jsontree



krimos
25 Jan 2011, 9:02 AM
Hi,
I'm newbie with Senchatouch library, and i found it very interesting.
However i have a serious problem with getNodeById(). I can't figure out how it works, and how can i use it in my context. I saw the documentation on : http://dev.sencha.com/deploy/touch/docs/ and tried a lot of tricks but my getNodeById() return undifined value.

Here is my code and what i'm trying to do :
I have a json file that contains items for categories list.



{
"text": "Items",
"id": 200,
"leaf": false,
"items":
[{"id":206,
"text":"Categorytitle1",
"leaf":false,
"items":[{"text":"Itemtitle2",
"leaf":true},
{"text":"Itemtitle3",
"leaf":true},
{"text":"Itemtitle3",
"leaf":true},
{"text":"Itemtitle4",
"leaf":true},
{"text":"Itemtitle5",
"leaf":true}
]},
{"id":207,"text":"Categorytitle2","leaf":false,"items":[ ...


In my script .js, i have put this code :


Ext.ns('catalog');
(function() {
var itemsUrl='data/items.json';

Ext.regModel('Items', {
fields: [
{name: 'id' , type: 'int'},
{name: 'text' , type: 'string'},
{name: 'leaf' , type: 'bool'},
{name: 'items' , type: 'tree'}


]
});

var treestore = new Ext.data.TreeStore({
model: 'Items',
proxy: {
type: 'ajax',
url: itemsUrl,
reader: {
type: 'tree',
root: 'items'

}
}
});

var store = treestore.getSubStore(treestore.getRootNode());
# Works perfectly with root node. i can see all the tree,

store = treestore.getSubStore(treestore.getNodeById(206));
#don't work :( !! need help !


My store must contain a part of tree defined by NodeId, and not all the tree.

Thanks for your help ;)