PDA

View Full Version : [CLOSED] javascript: has no method getNodeById of a TreePanel



CarpFisher
Sep 28, 2012, 2:47 PM
Hi

I've got a TreePanel like this:

<ext:TreePanel ID="tplTreePanel" runat="server" Height="600" Border="false" >
<View>
<ext:TreeView ID="TreeView1" runat="server">
<Plugins>
<ext:TreeViewDragDrop ID="TreeViewDragDrop1" runat="server" DDGroup="organizerDD" />
</Plugins>
</ext:TreeView>
</View>

<Store>
<ext:TreeStore ID="TreeStore1" runat="server" >
<Proxy>
<ext:AjaxProxy Url="ExtTreeLoader.ashx" />
</Proxy>
</ext:TreeStore>
</Store>


<Listeners>

<ItemContextMenu Handler="#{DirectMethods}.UpdateMenu(record.getId()); #{TreeContextMenu}.showAt(e.getPoint()); e.stopEvent();" />
<RemoteActionRefusal Handler="Ext.Msg.alert('Action refusal', e.message);" />
</Listeners>
</ext:TreePanel>

I referenced this TreePanel in some Handler like this:


Handler="#{tplTreePanel}.getNodeById ('123');"



However I've got the error telling me that the object does not have the method getNodeById.
I can see that in the actual execution it did translate that into

App.tplTreePanel.getNodeById('123');

And the App.tplTreePanel object looks like this:



body: constructor
$cache: Object
dom: HTMLDivElement
id: "tplTreePanel-body"
lastBox: Object
__proto__: TemplateClass
bodyCls: " x-grid-body"
border: false
checkNodesField: constructor
collapseDirection: "top"
columns: Array[1]
componentCls: "x-panel"
componentLayout: constructor
componentLayoutCounter: 7
container: constructor
ddPlugin: constructor
directListeners: Object
dockedItems: constructor
el: constructor
enableAnimations: function (animObj) {
events: Object
features: Array[0]
frame: undefined
hasDirectListeners: Object
hasListeners: HasListeners
hasView: true
headerCt: constructor
height: 600
hiddenOnCollapse: constructor
hideHeaders: true
id: "tplTreePanel"
initialConfig: Object
isContained: constructor
isDirectInit: true
items: constructor
lastBox: Object
layout: constructor
layoutCounter: 7
listeners: null
loader: null
managedListeners: Array[68]
mons: Array[0]
nsId: "App.tplTreePanel"
ownerCt: constructor
ownerLayout: constructor
plugins: undefined
protoEl: null
renderData: Object
renderSelectors: Object
rendered: true
root: Object
scrollTask: Ext.util.DelayedTask
selModel: constructor
selectionModelField: constructor
selectionSubmitConfig: Object
stateEvents: Array[0]
stateId: undefined
store: constructor
tools: Array[0]
ui: "default"
view: constructor
viewConfig: Object
xtype: "treepanel"
__proto__: TemplateClass


But

App.tplTreePanel.getStore().getNodeById('123')

did return a node. However that seems to be the datanode and not a treenode.....

What has I done wrong?

Daniil
Sep 28, 2012, 4:07 PM
App.tplTreePanel.getStore().getNodeById('123')

did return a node. However that seems to be the datanode and not a treenode.....

What has I done wrong?

Hi @CarpFisher,

Please clarify what do you mean by the "datanode" and "treenode" terms?

Generally, this method returns an Ext.data.NodeInterface object.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.TreeStore-method-getNodeById

CarpFisher
Sep 28, 2012, 4:54 PM
a node from the tree has the method setText() and property text while a data node doesn't have....

What I'm doing now is tell the store to load (reload actually) a particular node from the server. However the icon and text didn't change, only the children nodes get add/removed.... then I think I should just use setText() to change the text of the tree node, right? The only problem is I can't get the node from getNodeById from the TreePanel. InvokinggetNodeById on the store will return a node that doesn't have setText() method.

Daniil
Sep 28, 2012, 5:12 PM
There is no such method in ExtJS 4 / Ext.NET v2 anymore.

Please use:

node.set("text", "new text");

CarpFisher
Sep 28, 2012, 5:16 PM
Sorry I was referring to this:

http://forums.ext.net/showthread.php?10965-CLOSED-How-to-refresh-a-TreeNode-(attribute)-in-a-TreePanel

and I find that the API mentioned there is terribly out-dated.... so what should I use to set the text now? I didn't seem to be able to find anything from sencha's doc....

CarpFisher
Sep 28, 2012, 5:18 PM
it seems that we was writing to the thread the same time....

Thanks for the advice. Now my problem is how to get the updated
text property from the node, since it is not there anymore in the node interface?

Daniil
Sep 28, 2012, 5:24 PM
Please use:

node.get("text");

See also
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model-method-get

CarpFisher
Sep 28, 2012, 5:36 PM
Thanks. Yes I think I can guess that... however my problem is, get('text') is getting the text property of the node, however, when I called the
getStore().load({node: node}), I did update the text property in Ext.Net.Node in the server. However it doesn't got updated from the store and thus
get('text') is still the old text, not the updated one. Does that store load function only updates children nodes or does it actually store the new attributes somewhere I can retrieve?

Daniil
Sep 28, 2012, 5:58 PM
Is the node view updated with a new text after loading?

Please clarify which moment do you call the get method?

CarpFisher
Oct 01, 2012, 9:12 AM
The text on the node was not updated after I called


getStore().load({node: node})

I called that after the tree is fully loaded initially. Basically what I'm doing is I've got a Context menu "refresh" when right click on the node and after the user clicked on the context menu it will call that getStore().load() method. I'm sure that the server is returning the updated text at that moment however the node text is not updating on the tree after the method returned. Is it because I have to call something to redraw the node on the client side?

Daniil
Oct 01, 2012, 12:25 PM
I'm sure that the server is returning the updated text at that moment however the node text is not updating on the tree after the method returned.

Please clarify why are you sure?


Is it because I have to call something to redraw the node on the client side?

I am not sure how all is configured on your side, so, I cannot answer on this question.

A sample which would reproduce the problem would be appreciated.

CarpFisher
Oct 01, 2012, 2:23 PM
I am sure because I put a breakpoint on the server side function of the node load handler. After I clicked the 'Refresh' context menu the breakpoint paused and I examined the returning Node and it contains the updated text. Then I hit continue and it passed back to the browser but it didn't update the text. However, the children are all updated correctly. I seems that the store function only dates the children but no the text. I will try to create a simple sample code to make it clearer.

Daniil
Oct 01, 2012, 7:35 PM
Thank you for clarification.

An interesting issue. Please provide a sample to reproduce. We will do our best to investigate.