Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
340
How to get parent Node value while selecting child Node in XAMData Tree.
posted

Hi,

We are using XAMDataTree. and Hierarchy is Parent Node and then Child Node. If we Select Child Node then we are trying to get selected Child Node value along  with its parent Node Value. Right now We are only to get Parent Node Value not able to get selected Child Node value and Its Parent Node Value.

Please let us aware. Your help will be appreciate.

Thanks

Parents
  • 17475
    Offline posted

    Hello Piyu,

    XamDataTree node could be selected dynamically in code based on some custom logic by setting the XamDataTreeNode.IsSelected property to true. This could be achieved by handling the SelectedNodesCollectionChanged event and applying the logic there:
    private void tree1_SelectedNodesCollectionChanged(object sender, Infragistics.Controls.Menus.NodeSelectionEventArgs e)
            {
                if (e.CurrentSelectedNodes.Count > e.OriginalSelectedNodes.Count)
                {
                    XamDataTreeNode newSelectedNode = e.CurrentSelectedNodes[e.CurrentSelectedNodes.Count - 1] as XamDataTreeNode;
                    if ( newSelectedNode != null )
                    {
                        if (newSelectedNode.Manager.ParentNode != null && !newSelectedNode.Manager.ParentNode.IsSelected)
                        {
                            XamDataTreeNode parentNode = newSelectedNode.Manager.ParentNode;
                            parentNode.IsSelected = true;
                        }
                    }
                }
            }
    Please note that by default a single selection is enabled for the tree. The multiple selection should be allowed to have both the child and the parent selected:
    <ig:XamDataTree.SelectionSettings>
    <ig:TreeSelectionSettings NodeSelection="Multiple"/>
    </ig:XamDataTree.SelectionSettings>
    I am attaching a sample application that illustrates this behavior. If you have any questions on the same, do not hesitate to let me know.

    XamDataTreeSelectChildNode.zip
Reply Children