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

Programmatically Adding Data To Multicolumn Tree

I cannot find any samples to add multicolumned data to a TreeViewItemAdv control. I can add data to column 1 as follows:

<syncfusion:TreeViewAdv x:Name="myTreeView" Margin="0"  MultiColumnEnable="True" AllowDynamicResizing="True">
<syncfusion:TreeViewAdv.Columns>
<syncfusion:TreeViewColumnCollection>
<syncfusion:TreeViewColumn x:Name="column1" Header="column1" Width="100" />
<syncfusion:TreeViewColumn x:Name="column2" Header="column2" Width="100" />
<syncfusion:TreeViewColumn x:Name="column3" Header="column3" Width="100" />
</syncfusion:TreeViewColumnCollection>
</syncfusion:TreeViewAdv.Columns>
</syncfusion:TreeViewAdv>


TreeViewItemAdv node = new TreeViewItemAdv("value #1);
this.myTreeView.Items.Add(node);

This works, but how do I add values to the other columns?






3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team March 15, 2017 12:05 PM UTC

Hi Wesley, 
 
Thank you for using Syncfusion products. 
 
Query : I cannot find any samples to add multicolumn data to a TreeViewItemAdv control. But how do I add values to the other columns? 
 
From the above, we understand that you need to add the value in each column in TreeviewItemAdv. You can achieve this requirement is by using the cell template property of TreeViewColumn. Please find the code snippet for the same: 
 
Code Snippet:[XAML] 
 
 
<syncfusion:TreeViewColumn Width="200" Header="Name"> 
<syncfusion:TreeViewColumn.CellTemplate> 
<DataTemplate> 
<TextBlock Text="{Binding Name}"/> 
</DataTemplate> 
</syncfusion:TreeViewColumn.CellTemplate> 
</syncfusion:TreeViewColumn> 
<syncfusion:TreeViewColumn Width="300" Header="Description"> 
<syncfusion:TreeViewColumn.CellTemplate> 
<DataTemplate> 
<TextBlock Text="{Binding Description}"/> 
</DataTemplate> 
</syncfusion:TreeViewColumn.CellTemplate> 
</syncfusion:TreeViewColumn> 
 
 
 
Screenshot: 
 
 
 
Also for more information, please refer the following KB link  
 
 
 
 
If we have misunderstood on the reported requirement, please brief about your requirement clearly by providing screenshot. It would helpful for us to proceed further on this. 
 
Regards, 
Vijayalakshmi V.R. 



WW Wesley Witt March 15, 2017 01:40 PM UTC

Thanks for the response, but the sample does not do what I need. Your sample uses a view model and data binding to display the data. This is not what I need to do. As I showed in the code snippet below I want to know how to add multi-column data to the tree programatically by manually inserting the data into the tree.  How can I add multi-column data into the items manually??


VR Venkateshwaran Ramdoss Syncfusion Team March 16, 2017 05:51 PM UTC

Hi Wesley,

Thank you for your update.

We have analyzed your query. At present, there is no support available to add the multi column data in MultiColumnTreeView without using ItemsSource. In SfTreeGrid control, we have support to load the data in on-demand throughSfTreeGrid.RequestTreeItems event without using ItemsSource. SfTreeGrid gets the root and leaf nodes through this event handler.Could you please refer the below link.

https://help.syncfusion.com/wpf/sftreegrid/getting-started#populating-treegrid  

While using RequestTreeItems event, you can’t directly add the node in treegrid instead of that you need to add the item using AddNode method at runtime. Could you please refer the below attached sample,

Sample: http://www.syncfusion.com/downloads/support/forum/129374/ze/SfTreeGrid_DemoSample404012310   

For more details about AddNode method, refer the below link
https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.Helpers.TreeGridHelper.html#Syncfusion_UI_Xaml_TreeGrid_Helpers_TreeGridHelper_AddNode_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_Syncfusion_UI_Xaml_TreeGrid_TreeNode_System_Object_  

Please let us know if you have any query.

Regards,
Venkateshwaran V.R. 


Loader.
Live Chat Icon For mobile
Up arrow icon