PDA

View Full Version : Ext.data.NodeInterface not accepting config options



pflammer
28 Oct 2011, 8:17 AM
I am adding in nodes to a tree. The way I am doing this is:



var nodeConfig = { leaf:true,
text:"some text,
cls:"",
iconCls:""
};
var treeNode = new Ext.data.NodeInterface(nodeConfig);

But once I get treeNode, text is blank, and leaf is false. Any ideas of why that might not take? It renders that way as well (as a folder and with no text).

Note: I used firebug to tell me what the text and leaf are after the definition. I then used an appendChild statement to the root node to add it to the tree, which is where it rendered incorrectly as well.

skirtle
28 Oct 2011, 9:56 AM
You can't create an instance like that. NodeInterface is a decorator.

Just pass your node config to the appendChild() method, it'll do all the work for you. If you want to create an instance yourself then it'll need to be an instance of the model that backs the store, not NodeInterface.

If you want to see the full gory details of how this all works then take a look at the code for appendChild().

pflammer
28 Oct 2011, 11:13 AM
Thanks. That does answer the question. The API doc was written saying to pass it an instance of an Ext.data.NodeInterface. Passing just the config did fix the issue. Thanks very much.

The api doc was here.
https://72.1.109.240:49324/esp/js/ext/docs/#!/api/Ext.data.NodeInterface
(https://72.1.109.240:49324/esp/js/ext/docs/#!/api/Ext.data.NodeInterface)