Devexpress TreeList Child nodes - winforms

How can i programmatically focus on child node in DevExpress TreeList?
Firstly i have to get selected node (parent or child) and then i have to focus on that node.
I tried using FocusedNode but i can only focus on parent node.
Example:
2013
2014
3
12 <- i want focus on this child node
What i'm getting using FocusedNode:
2013
2014 <- FocusedNode
3
12
Regards.

Firstly you need to find the child node and then just set it in the TreeList Focused node. Sample code in VB.Net is given below:
Dim NodeID As String = "some id" 'Set the child node id in this variable
Dim node = TreeList1.FindNodeByKeyID(NodeID)
TreeList1.FocusedNode = node

Related

not able to display a textfield or button on extjs tree node

I have an extjs tree. I can add tree nodes dynamically to the selected node. But to the newly added node I need a textfield too attached with it.
screenshot

appendChild does not put expand collapse icon in tree panel

expand/collapse icon is not shown after adding the child node to tree panel in extjs.
here i have a scenario where i get only immediate childrens of the node. on getting the immediate childrens i want to add those to the selected node.
i can add the child nodes but the expand/collapse icon does not come up after adding the node.
following is my code.
onItemExpand : function(nodeinterface,eOpts)
{
if(!nodeinterface.hasChildNodes())
{
nodeinterface.appendChild(dataFromES[0]);
}
}
here the data contains the property leaf:false so that it can have more childs.
any help is really appreciated.
Thanks
Set the parent node (in your case the nodeinterface variable) "leaf" property to false before you append a new child.
if(!nodeinterface.hasChildNodes())
{
nodeinterface.set('leaf', false);
nodeinterface.appendChild(dataFromES[0]);
}
I've experienced the same problem and in my case the problem was related with the lack of the id property in the nodes.
I've added a random id when creating the nodes to append and then the expand/collapse icon is properly shown.
Alex

ExtJs 4.1.1 Tree Panel node selection logic

I am using tree panel is ExtJS.
Consider the above image as the tree panel. If user selects node 1.1.1.2, I should check if all its sibling are also checked/selected, if yes, system should select 1.1.1 node and deselect 1.1.1.1, 1.1.1.2, 1.1.1.3 nodes.
Similarly, At this point I should check the siblings of 1.1.1 node (1.1.2 & 1.1.3) & if they previously selected/checked, then I should deselect 1.1.1, 1.1.2, 1.1.3 and I should select 1.1 node.
This kind of check continues until I reach root node or one the siblings of selected node is not checked/selected.
What is the best way to achieve this. When I say best way, I am looking for some in-build property or method which will help me achieve this.
Thank you
I would start with the bubble method:
http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.data.NodeInterface-method-bubble

In ExtJS 4, How do you delete a tree node when the associated grid information to the node is deleted at random

My code so far populates via drag and drop tree nodes and leaves from a grid panel. I want to know how to remove a tree node when the grid information associated with it is removed.
You should have something like id property in your model both in grid and tree. So when you remove record in the grid you then search for the node with this id in tree and remove it as well. Another way is just save the reference to the node when you drop it.
The flow is:
user drags and drops record from grid to the tree
when the record is dropped and new node is created you save reference in the grid's record
onNodeDrop: function(){
grid.getSelected().treeNode = tree.lastCreatedNode;
}
then when you delete record in grid you could delete node as well.
Note - this is just a psuedocode, is won't work. Just to give you an idea.

C# WinForms - TreeView, Context Menu

Suppose I am using a context menu to add child nodes to a treeview control.
(1) I am right-clicking on the node
(2)context menu pop up
(3)then I click "Add" menu item
(4)a dialogBox opens up
(5) I input the name in that DialogBox and press OK
(6) A new Node is created.
How can I get the reference of the current Node when I am clicking on the context menu item?
I need this coz the parent object is stored in the Tag property of the current node.
If you handle TreeNodeMouseClick, then your TreeNodeMouseClickEventHandler will be passed a TreeNodeMouseClickEventArgs argument.
TreeNodeMouseClickEventArgs.Node will be the TreeNode reference you want. See the TreeNodeMouseClick docs for an example similar to:
void treeView1_NodeMouseClick(object sender,
TreeNodeMouseClickEventArgs e)
{
TreeNode theTreeNodeIWant = e.Node
}
If you need to, you can store a reference in a member variable so another method can access it.
You can get the mouse position from
System.Windows.Forms.Cursor.Position
Save this before showing the context menu.
Then use the method on the Treeview containing your items
GetChildAtPoint(Point)
and add a child below that.

Resources