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

SfDataGrid column with multiple buttons

Hi Team,

I am experimenting with the SfDataGrid and would like to know how to assign multiple buttons in a sfdatagrid column. Here number of buttons for a column might be different for each row. Please help on this issue.

Kind regards,

1 Reply

DB Dinesh Babu Yadav Syncfusion Team April 23, 2019 06:29 AM

Hi Brijesh, 
Thank you for contacting Syncfusion Support. 
We have analyzed your query to have different number of buttons in each row of SfDataGrid. And your requirement can be achieved by using GridTemplateColumn and CellTemplateSelector as like below code snippet 
public class GridCellTemplateSelectorEXt : DataTemplateSelector 
        public override DataTemplate SelectTemplate(object item, DependencyObject container) 
            if (item == null) 
                return null; 
            if (((item as OrderInfo).OrderID % 2) == 0) 
                return App.Current.MainWindow.Resources["template1"] as DataTemplate; 
                return App.Current.MainWindow.Resources["template2"] as DataTemplate; 
        <DataTemplate x:Key="template1"> 
            <StackPanel Orientation="Horizontal"> 
                <Button Content="B1" Margin="5"/> 
                <Button Content="B2" Margin="5"/> 
                <Button Content="B3" Margin="5"/> 
        <DataTemplate x:Key="template2"> 
            <StackPanel Orientation="Horizontal"> 
                <Button Content="B1" Margin="5"/> 
                <Button Content="B2" Margin="5"/> 
        <local:GridCellTemplateSelectorEXt x:Key="template"/> 
<syncfusion:GridTemplateColumn MappingName="CustomerID"  
                               CellTemplateSelector="{StaticResource template}"  
Please find sample for the same from the below link 
Sample Link: 
Also please refer to the below KB article to know more details on GridTemplateColumn 
KB Link: 
Please let us know, if you need any further assistance on this. 
Dinesh Babu Yadav. 

Live Chat Icon For mobile
Up arrow icon