PDA

View Full Version : Expanding Tree Nodes Using a REST Proxy



billtricarico
5 Dec 2011, 9:54 PM
Hello,

I have a basic tree bound to a store with a REST proxy. This loads the tree as expected. I am purposely only returning one level of children so as not to load the entire tree. In each child node I have a 'url' property that represents a REST url to load that node's children.

I want to be able to click on that node and use it's 'url' property to load its children. But whenever I click the node, it instantly calls the store proxy url. I tried setting the url in the itemclick event handler but that doesn't work. Instead I get this error:
Uncaught TypeError: Cannot read property 'internalId' of undefined.

Can anyone help me to understand how to use REST with a tree?

flanders
5 Dec 2011, 10:15 PM
The default behaviour of the restproxy is that it throws all it's actions at the same url. In the case of a tree this means that all the loading is done from the same url providing an extra POST parameter which node is to be loaded. So the default behaviour sticks to one url only.

If you cannot change your serverside, the best think to do is take a look at buildUrl() of the rest proxy. You should be able to change the url here.

(In the context of assocations to other models, there has been some talk that a proper RESTful implementation should handle url's provided in the response to retrieve related data. http://www.sencha.com/forum/showthread.php?130148-EXTJSIV-3425-Proper-support-of-RESTful-applications)

billtricarico
22 Dec 2011, 11:52 AM
I think the best thing to do is stay away from REST until it works as expected.