We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

add custom controle in child node.

hi,
I am using syncfusion TreeViewAdv controle where i have four Parent node ,then each parent node have about 30 child node.
now i want to add separate Gridgrouping control  with datasource as datatable as custom control to every child node.
also i want to retreive  table binded to  perticular child node.
is there any solution please provide me in detail.
thanks.

3 Replies

SK Senthil Kumaran Rajan Syncfusion Team December 30, 2015 06:33 AM UTC

Hi Rasika,

Thank you for using Syncfusion products.

The reported requirement can be achieved by using Custom control property in TreeNodeAdv. Please refer the below code example. 

Code Snippet[C#]:

int i = 0;
int TotalNodeCount = 4;
//To add the Parent node
for (i = 0; i < TotalNodeCount; i++)
     {
           TreeNode = new TreeNodeAdv();
           TreeNode.Text = "node" + nodenumber.ToString();
           nodenumber++;
           this.treeViewAdv1.Nodes.Add(TreeNode);
      }
 
     //To Add child node
     foreach (TreeNodeAdv node in this.treeViewAdv1.Nodes)
     {
         for (int childnode = 0; childnode <= 30; childnode++)
            {
                TreeNode = new TreeNodeAdv();
                TreeNode.Text = "node" + nodenumber.ToString();
                nodenumber++;
                node.Nodes.Add(TreeNode);
            }
     }
 
     for (int addcustom = 0; addcustom < 4; addcustom++)
     {
           //To add the GridGrouping Control.
           foreach (TreeNodeAdv node in Collect(this.treeViewAdv1.Nodes[addcustom].Nodes))
           {
                GridGroup = new GridGroupingControl();
 
                GridGroup.GridVisualStyles = GridVisualStyles.Metro;
                GridGroup.TopLevelGroupOptions.ShowCaption = false;
                if (node.CustomControl == null)
                  {
                      node.CustomControl = GridGroup;
                      GridGroup.DataSource = dt;
                      node.CustomControl.Width = 300;
                      node.Height = 80;
                   }
            }
     }


We have also prepared a sample for your reference and it can be downloaded from here.

Sample : http://www.syncfusion.com/downloads/support/forum/121548/ze/TreeCustom-1374470462

Please refer the below Knowledge Base to add the custom control in TreeViewAdv.

KB Link : http://www.syncfusion.com/kb/4666/how-to-add-custom-controls-in-treeviewadv

Please let us know if you need further assistance.

Regards,
Senthil.



RA Rasika December 30, 2015 07:15 AM UTC

thanks for reply.
your solution works for me.
but now i want to retreive datatable bind to  ggc of perticular child node of corresponding parent node in treeviewadv.
is there any solution to achieve this.

regards,
Rasika.


SK Senthil Kumaran Rajan Syncfusion Team December 31, 2015 09:57 AM UTC

Hi Rasika,

 

Thanks for contacting Syncfusion Support.

 

The DataTable can be retrieved from GridGroupingControl which is loaded as custom control for TreeNodeAdv, by using the below code example.

 

Code Example[C#]:

 

if (this.treeViewAdv1.SelectedNode != null && this.treeViewAdv1.SelectedNode.CustomControl != null)
            {
                //To get the DataTable from GridGroupingControl.
                foreach (DataRow dr in ((this.treeViewAdv1.SelectedNode.CustomControl as GridGroupingControl).DataSource as DataTable).Rows)
                {
                    //To get the Row value from DataTable.
                    this.listBox1.Items.Add(dr["FirstName"].ToString());
                }
            }
 

 

We have prepared a sample and video for your reference and it can be downloaded from the following location.

 

Sample : http://www.syncfusion.com/downloads/support/forum/121548/ze/TreeCustom-571415503

 

Video : http://www.syncfusion.com/downloads/support/forum/121548/ze/CustomControlNode-1810720342

 

Regards,

Senthil


Loader.
Live Chat Icon For mobile
Up arrow icon