-
19 May 2012 12:47 AM #1
Answered: extjs 4.1 tree refresh a specific node
Answered: extjs 4.1 tree refresh a specific node
I would like to refresh a node of a tree.I try something like that to refresh the root and it worked:
But now I would like to refresh only one Node and not the whole tree.Code:this.getStore('MyTreeStore').load({ params: { id: this.getId().getValue()} });
-
Best Answer Posted by Ujjwal Reddy
If you want to load a particular node, then pass a node/record object in the store's load() call. This will load the data of that node (similar to an expand request of the node).
Code:this.getStore('MyTreeStore').load({ node: someNode});
-
21 May 2012 1:39 AM #2
-
21 May 2012 5:50 AM #3
Why just not:
PHP Code:var rowId = 1,
columnDataIndex = 1,
node = treepanel.getStore().getNodeById(rowId);
node.set(columnDataIndex, value);
-
21 May 2012 7:01 AM #4
but it will make an update request, is it possible without that ? Just make a GET request to the server for a specific node.
-
21 May 2012 10:42 PM #5
I don't understand you. This node is specified by rowId and columnId. It node.set will update only this one node.
-
22 May 2012 3:32 AM #6
Yes but it change the data of my node and I don't want to change the data, I just want to refresh.
Is there any other way to make a refresh rather than update the node ?
-
23 May 2012 1:44 AM #7
If you want to load a particular node, then pass a node/record object in the store's load() call. This will load the data of that node (similar to an expand request of the node).
Code:this.getStore('MyTreeStore').load({ node: someNode});
-
23 May 2012 2:52 AM #8
Thanks it works. I just have another question.
When I reload the node and the name changed. The tree node keeps the old name, actually it's the "text" property. Should I put the record property under a specific property or is the response correct ?
Or should I reload the parent to get the new name ?Code:{ text: 'New Name', children: [array with child nodes], success: true }
I think it's related to the issue: http://www.sencha.com/forum/showthre...server-changes
-
23 May 2012 3:32 AM #9
The load() call works just for loading the child nodes of the tree (similar to expanding the node - it doesn't change the expanded node's properties, but gets the child tree nodes). To get the new name, you might want to consider loading the parent tree node (but this loads all its child nodes and might not be an efficient solution).
If you know the new name before hand, then you use the following -
This will set the name to the new name and commit the record to the store locally. But if the new name can only be gotten from the server, then consider getting the new name through an AJAX request and then using the above code to display the new name.Code:node.set('text', 'New Name'); node.commit();
-
25 May 2012 6:51 AM #10
Thanks for your answer that's inspired me.
I make a small workaround, it's a bit quick and dirty but it work as I expect.Code:Ext.data.Operation.override({ setCompleted: function() { this.complete = true; this.running = false; if (this.action === 'read' && this.node && this.response) { data = Ext.decode(this.response.responseText); if (Ext.isObject(data.node)) { for (var key in data.node) { this.node.set(key, data.node[key]); } this.node.commit(); } } } });
The server just need to send a response like that:
Code:{ node: { text: 'New Name' }, children: [array with child nodes], success: true }


Reply With Quote