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
close icon

Bind different sources to SfTreeGrid's templated cells

I'm trying to use SfTreeGrid to display "Tests" and "Profiles" (the profiles contains other tests). I have two columns Name and Result, and templates (textboxTemplate and comboboxTemplate) to customize result's cell. Some of the tests have a text result, but others needs combobox to select an option. Each combobox shoud contains different options depending on the test. Could you please give me a hint how can I fill ItemSources of the comboboxes? Is it possible to do that with SfTreeGrid or I need another control?
Thanks for your help.

1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team March 14, 2017 01:40 PM UTC

Hi Ivailo, 

Thank you for contacting Syncfusion support. 

We have analyzed your query. You can bind the different ItemsSources to each row of the ComboBox by using GridTemplateColumn in the SfTreeGrid as like below code snippet. 

Code Snippet:  

<syncfusion:TreeGridTemplateColumn HeaderText="ShipCity"  MappingName="CityId" syncfusion:FocusManagerHelper.WantsKeyInput="True"> 
            <TextBlock Text="{Binding CityId}" HorizontalAlignment="Right" /> 
            <ComboBox ItemsSource="{Binding CityDescription, Converter={StaticResource converter}}"  
                    SelectedItem="{Binding CityId,Mode=TwoWay}"/> 

The ItemsSource for each row of the ComboBox is set based on the CityDescription with the help of converter as below code, 

public class ItemsSourceConverter:IValueConverter 
    ShipCityDetailsRepository ShipCity = new ShipCityDetailsRepository(); 
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        string[] shipcities=null; 
        //Check whether the  CityName contains  which is received from value parameter 
        if (ShipCity.ContainsKey(value.ToString())) 
            //if the key matched , it will return the corresponding shipcities  
            ShipCity.TryGetValue(value.ToString(), out shipcities); 
            return shipcities; 
        return null; 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        throw new NotImplementedException(); 

Please let us know if you have any query. 

Muthukumar K 

Live Chat Icon For mobile
Up arrow icon