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.
Unfortunately, activation email could not send to your email. Please try again.

Using HierarchicalDataTemplate with SfTreeGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hello,

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.

Thanks,

Mathieu

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

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. 
 
Thanks, 
Sivakumar 


Mathieu Belanger
Replied On January 17, 2017 09:14 PM

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

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

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


Mathieu Belanger
Replied On January 20, 2017 06:33 PM

Hello,

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 23, 2017 09:29 PM

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. 

Regards, 
Muthukumar K 


Mathieu Belanger
Replied On January 24, 2017 09:30 PM

Hi,

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,

Mathieu

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

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. 
Regards, 
Ashwini P. 


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.

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.

;