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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Programmatically Adding Data To Multicolumn Tree

Thread ID:

Created:

Updated:

Platform:

Replies:

129374 Mar 15,2017 01:08 AM UTC Mar 16,2017 05:51 PM UTC WPF 3
loading
Tags: TreeViewAdv
Wesley Witt
Asked On March 15, 2017 01:08 AM UTC

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?






Vijayalakshmi Roopkumar [Syncfusion]
Replied On 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. 


Wesley Witt
Replied On 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??

Venkateshwaran Ramdoss [Syncfusion]
Replied On 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/cref_files/wpf/sfdatagrid/Syncfusion.SfGrid.WPF~Syncfusion.UI.Xaml.TreeGrid.Helpers.TreeGridHelper~AddNode.html  

Please let us know if you have any query.

Regards,
Venkateshwaran V.R. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;