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

Adding different types in the same column in Sfdatagrid

How can add different types in the same column in SfDataGrid? For example, I want to have both comboboxes and normal textblocks in a single column. Is there any way to do that? Thanks in advance.

1 Reply

JG Jai Ganesh S Syncfusion Team June 22, 2016 01:52 PM UTC

Hi Aayush, 
You can achieve your requirement to load the different types in same column by using CellTemplateSelector like below, 
    <DataTemplate x:Key="CellTemplate1"> 
            <ComboBox Grid.Column="0" Height="35" Width="165"> 
    <DataTemplate x:Key="CellTemplate2"> 
        <TextBlock Foreground="DarkRed" Text="{Binding Path=Value}" /> 
<syncfusion:GridTemplateColumn MappingName="UserId" Width="300" SetCellBoundValue="True"  CellTemplateSelector="{StaticResource selector}"> 
public class EditTemplateSelector : DataTemplateSelector 
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) 
            if (item != null) 
                var data = (item as DataContextHelper).Record as UserInfo; 
                if (data.UserId < 1015) 
                    return Application.Current.Resources["CellTemplate1"] as DataTemplate; 
                    return Application.Current.Resources["CellTemplate2"] as DataTemplate; 
            return base.SelectTemplateCore(item, container); 
Jai Ganesh S 

Live Chat Icon For mobile
Up arrow icon