PDA

View Full Version : Disabling a node in a dialog window's TreePanel



dana.lees
17 Sep 2009, 1:29 AM
hello,

I have a form with a TreePanel, which after selecting a node, I am opening a dialog with a similar TreePanel. I would like to disable the selected node in my form, in the dialog's TreePanel.

Here is the relevant code:



copyWindow = Ext.extend(Ext.Window, {
layout: 'fit',
initComponent: function() {
copyWindow.superclass.initComponent.call(this);

var Tree = Ext.tree;
var root = new Tree.AsyncTreeNode({
text: 'copy',
draggable: false,
expanded: true,
rootVisible: false,
id: '0'
});

this.treePanel = new Tree.TreePanel({
id:'copyTree',
containerScroll: true,
loader: new Tree.TreeLoader({

dataUrl: 'WS.asmx/getGroups'
}),

selModel: new Tree.MultiSelectionModel(),
root: root,
rootVisible: false
});

this.add(this.treePanel);
});

//the node selected in my form
var selectedNode = groupsTree.getSelectionModel().getSelectedNode();
var win = new copyWindow();
win.show();
win.get('copyTree').getSelectionModel().select(selectedNode).disable();


What I actually see is that the node is disabled in my form's TreePanel instead of the dialog's TreePanel.
Why is that?

Thanks

evant
17 Sep 2009, 4:43 PM
Duplicate id possibly? You haven't really shown enough code.

dana.lees
20 Sep 2009, 10:45 PM
There are no duplicate IDs.

I'll post some more code:

My TreePanel on my form:



var tree = new Tree.TreePanel({
title: 'groups',
animate:true,
enableDD:false,
rootVisible : false,
loader: new Tree.TreeLoader({
dataUrl:'WS.asmx/GetGroups'
})
});
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'groups',
draggable: false,
expanded: false,
id:'0'
});


the windowDialog object:


copyWindow = Ext.extend(Ext.Window, {
layout: 'fit',
initComponent: function() { copyWindow.superclass.initComponent.call(this);

var Tree = Ext.tree;
var root = new Tree.AsyncTreeNode({
text: 'copy',
draggable: false,
expanded: true,
rootVisible: false,
id: '0'
});

this.treePanel = new Tree.TreePanel({
id:'copyTree',
containerScroll: true,
loader: new Tree.TreeLoader({

dataUrl: 'WS.asmx/getGroups'
}),

selModel: new Tree.MultiSelectionModel(),
root: root,
rootVisible: false
});

this.add(this.treePanel);



The code which opens the window dialog:


//the node selected in my form
var selectedNode = groupsTree.getSelectionModel().getSelectedNode();

var win = new copyWindow();
win.show();

//getting the tree object in the opened dialog window i norder to disable the node selected previously
win.get('copyTree').getSelectionModel().select(selectedNode).disable();

Animal
20 Sep 2009, 11:07 PM
You are ASKING for the original node to be disabled. You are asking for selectedNode to be disabled.

Passing it through the select method of a SelectionModel has no effect. It's the same node.

dana.lees
20 Sep 2009, 11:11 PM
Can you please help me or direct me on how I can find the node I want in the dialog window's tree?
How can I select the node I need?

Thank you

Animal
20 Sep 2009, 11:13 PM
Dunno. What node DO you need?

dana.lees
20 Sep 2009, 11:18 PM
I have a tree on a form. The user selects a node and presses a "copy" butoon.
In the opened dialog I show a tree in which I want to show the same nodes as in the form's tree, except that the node that was selected in the form should be disabled in the dialog (as the user cannot copy the node to itself)

pawelb1973
20 Sep 2009, 11:27 PM
Do you tried to events?
Simply set tree listener on event 'click' or 'dblclick' or (if you open context menu) fire event for example 'CopyWindow' and set listener event on it.
Event listerener should open new window with data passed by event (see API doc for tree events 'click' and dblclick). I'm using Remote Tree Panel extension from Saki's website: http://remotetree.extjs.eu.

dana.lees
20 Sep 2009, 11:36 PM
Thanks,
I am not sure why I should use events. I am using a "copy" button which opens a dialog when clicking on it and displays the same tree as in my original form.
All that works fine,
I just need to find a specific node on the dialog window and disable it.

Animal
20 Sep 2009, 11:57 PM
Disable the node with the same id.

I think Node IDs must only be unique within the tree, so if the tree is s duplicate, then the IDs will be the same.

dana.lees
21 Sep 2009, 12:33 AM
I was trying the following (with a hard-coded node ID that i know, for sure, that exists on the tree):

win.get('copyTree').getNodeById(1).disable();


That failed because "win.get('copyTree').getNodeById(1)" is undefined.
This is strange because I do see on the opened dialog exactly the same tree nodes and contents as in the original tree.

pawelb1973
22 Sep 2009, 12:21 PM
I was trying the following (with a hard-coded node ID that i know, for sure, that exists on the tree):

win.get('copyTree').getNodeById(1).disable();


That failed because "win.get('copyTree').getNodeById(1)" is undefined.
This is strange because I do see on the opened dialog exactly the same tree nodes and contents as in the original tree.

Try to use
Ext.getCmp('copyTree')I'm afraid of 'win.get' will not work because the call it returns the element component contained in the 'win'. API Doc says:
get( String/Number key ) : Ext.ComponentGet a component contained by this container (alias for items.get(key))Trying to use Firebug? Firebug is a tool for debugging in the Firefox browser window.
Try to use
console.log(win.get('copyTree'))
and see what call of console.log returns.

Vihar
10 Dec 2014, 4:41 AM
Hai every one ,i have a doubt that is there any possibility to disable or enable a particular node in tree panel

Vihar
10 Dec 2014, 4:45 AM
hai animal can you please help me in the node disable issue.
I have a tree with many childs.......but i need to disable a particular node.
can you please help me.There is no method for disabling OR enabling a single node in Ext.data.NodeInterface and Ext.data.NodeStore in sencha4.07 api