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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using HierarchicalDataTemplate with SfTreeGrid

Thread ID:





128359 Jan 17,2017 05:18 AM UTC Jan 25,2017 10:31 AM UTC WPF 7
Tags: SfTreeGrid
Mathieu Belanger
Asked On January 17, 2017 05:18 AM UTC


I'm used to work with TreeView in WPF and typically, when you need to have specific behavior for different nodes (for exemple, a folder, a file), you can use HierarchicalDataTemplate. It also seemed to be the case with syncfusion.treeviewadv. But I can't find how to set it up on SfTreeGrid. In TreeViewAdv, you can use syncfusion:TreeViewAdv.ItemTemplate but it's nowhere to be found in SFTreeGrid. Is it supported? 

I've seen the IValueConverter, but I wasn't sure if it was intended as a full replacement for datatemplate.



Sivakumar R [Syncfusion]
Replied On January 17, 2017 06:11 AM UTC

Hi Mathieu, 
SfTreeGrid is a column based on control where on row will have multiple cells and TreView is a row based control where it has only single column. 
So, SfTreeGrid provides ways to customize or load template on column basics.  
Refer the below documentation link which explains how to generate columns and different columns supportted. 
You can use TreeGridColumn.CellTemplate or TreeGridColumn.CellTemplateSelector to achieve your requirement. 

Mathieu Belanger
Replied On January 18, 2017 02:14 AM UTC

Thanks for the quick answer. I'll have a look.

Ashwini Paranthaman [Syncfusion]
Replied On January 18, 2017 06:55 AM UTC

Hi Mathieu, 
Thank you for the update. 
We will wait to hear from you. 
Ashwini P. 

Mathieu Belanger
Replied On January 20, 2017 11:33 PM UTC


Sorry for my late answer. I've been able to make it work properly using CellTemplateSelector. I can now have custom cell look and feel and custom context menu depending on my type of item.

However, it doesn't help with the fact that using hierarchicalDataTemplate, I was able to specify an itemsource pointing to my MVVM. And when I was adding or removing a item to my model, it was automatically added to the tree which is not the case with sftreegrid. I've not find the best way to use TreeBehavior properly modify the content of my viewmodel without having to directly call the sftreegrid. Is it possible to do it?

Thanks again

Muthukumar Kalyanasundaram [Syncfusion]
Replied On January 24, 2017 02:29 AM UTC

Hi Mathieu,  

Thanks for the update. 
We couldn’t get your requirement clearly. So, we created the sample based on our understanding. On below attached sample, we have added or removed item in collection at run time using commands. If the data source implements INotifyCollectionChanged interface, then SfTreeGrid control will automatically refresh the UI when item is added, removed or while list cleared. If your requirement is different from this, could you please explain your requirement clearly? This would be more helpful for us to proceed further.    
Please let us know if you have any concern. 

Muthukumar K 

Mathieu Belanger
Replied On January 25, 2017 02:30 AM UTC


Thanks you for your support, it is really appreciated. I've taken a look at your sample and it helped me simplify my code. I was trying to port something complex to the treegrid. I decided to get rid of load on demand to load everything straight to memory and I've been able to make everything work. I'll be able to build on that for now on.

Thanks again,


Ashwini Paranthaman [Syncfusion]
Replied On January 25, 2017 10:31 AM UTC

Hi Mathieu, 
Thank you for the feedback. 
We are glad that your requirement has been met. 
Please let us know if you need any other assistance. 
Ashwini P. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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