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

Capture value in datatemplate assigned to checkbox column

Hello, how are you?

I have a sfdatagrid that is shared by the whole application, in this scenario there may be cases of having more than one column of the chechbox type.

What I'm doing is assigning a template to these checkbox columns.

What I need is to take the value of this cell and then apply a converter and use icons.

In the documentation I saw an example, but the column name is passed there, but it doesn't work for my scenario, because I need this to be dynamic, as I will have several checkbox columns and with different names.

I also saw it on the internet saying to use {Binding CellBoundValue}, I tried it and was unsuccessful. If I use the column name it works, but then I will have to make a very large template with all the column name options. Totally unfeasible.

Attached are the images that will show how I am doing.

Attachment: TS_2941326.rar

3 Replies

SA Saravanan Ayyanar Syncfusion Team February 6, 2020 01:35 PM UTC

Hi Tech Shop, 
Thank you for using Syncfusion controls. 
You can achieve your requirement of “Same template apply different column” by setting the Binding as Value and SetCellBoundValue as true. Please refer the below code snippet. 
<DataTemplate   x:Key="cellTemplate"> 
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> 
        <Button Content="{Binding Path=Value,Converter={StaticResource converter}}" Width="70" Height="25" /> 
        <TextBlock  Foreground="Red" 
            Text="{Binding Path=Value, Converter={StaticResource converter}}"/> 
        <CheckBox IsChecked="{Binding Path=Value,Converter={StaticResource converter}}"/> 
     e.Column = new GridTemplateColumn() 
         MappingName = e.Column.MappingName, 
         CellTemplate = Application.Current.FindResource("cellTemplate") as DataTemplate 
Sample Link: 
UG Link: 
Please let us know, if you require further assistance on this. 
Saravanan A. 

TS Tech Shop February 6, 2020 04:31 PM UTC

Hi Saravanan,

Worked perfectly. Thank you very much for your assistance.

FP Farjana Parveen Ayubb Syncfusion Team February 7, 2020 06:28 AM UTC

Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Farjana Parveen A 

Live Chat Icon For mobile
Up arrow icon