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

DataBind CheckBox Grid Column

I have a databind DataGrid column  (Active) that is a boolean type (True/False or 1/0) ...

I want to display these column as checkbox, but not select the row ...


These code  for <e-column field="Active" [displayAsCheckBox]= "true"></e-column>  does not work
and these <e-column field="Active" headerText="Ativa" type="checkbox" rowSelected="false" width="50" ></e-column>
select the rows ...

<ej-grid id="g1" [dataSource]="empresas" allowPaging="true"
[toolbarSettings]="toolbarItems" [editSettings]="editSettings" >
<e-columns>
<e-column field="Id" headerText="ID" [isPrimaryKey]="true" ></e-column>
<e-column field="Name" headerText="Company"></e-column>
<e-column field="Nick" headerText="Nick"></e-column>
<e-column field="Active" [displayAsCheckBox]= "true"></e-column>
<e-column field="Active" headerText="Ativa" type="checkbox" rowSelected="false" width="50" ></e-column>
</e-columns>
</ej-grid>

What´s the right way to do these ?


6 Replies

MB Marcelo Blank August 29, 2017 01:08 AM UTC

Follow the grid



MS Mani Sankar Durai Syncfusion Team August 29, 2017 12:31 PM UTC

Hi Marcelo, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we found that you would like to show the column as checkbox when data is either true/false or 0/1. To achieve this we suggest you to set the type as “boolean” and when the type is “checkbox” it will select the rows when checking the checkbox. 
Refer the code example 
<e-column field=”Active” type=”boolean” [displayAsCheckBox] = “true” /> 

Note: if the checkbox should not select the row when checking don’t use the type as checkbox instead use it as Boolean. 
Refer the documentation link. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 



MB Marcelo Blank August 29, 2017 12:48 PM UTC

Great Manisankar

Works perfectly...


Regards,

Marcelo




MS Mani Sankar Durai Syncfusion Team August 30, 2017 06:20 AM UTC

Hi Marcelo, 

We are happy to hear that your problem has been solved.  

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 



AP Aditi Patre September 18, 2018 05:26 AM UTC

Unable to bind checkbox to a column (which holds boolean value) in a grid.

I'm creating a list of syncfusion grid columns
List<Column> cols = new List<Column>();

Dictionary<string, object> ReadOnlyDict = new Dictionary<string, object>();
 ReadOnlyDict.Add("style", "background-color:#eeeeee");


Adding column of boolean datatype to grid:

cols.Add(new Column() { Field ="ColumnName", HeaderText = "ColumnName", HeaderTooltip ="", Type = "boolean", DisplayAsCheckbox = true, TextAlign = TextAlign.Center, AllowEditing = false, Visible = true, CustomAttributes = ReadOnlyDict});

The grid does display checkbox but it isn't able to bind with the bit datafield. So although the value in database is 0 it is always mapping it as checked.


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team September 18, 2018 10:23 AM UTC

Hi Aditi,  
 
Based on the given code example, we have prepared a sample in the latest version of the Essential Studio ASP.Net MVC platform. The sample can be downloaded from the following location. 
 
 
We cannot reproduce the reported problem at our end. We have used the 0’s and 1’s as the value for the Boolean column which is binding value to the checkbox correctly. Please share the following details to analyze the problem at our end. 
 
  1. Essential studio version.
  2. Complete code example of the Grid (view and controller page)
  3. Model class of the Grid datasource
  4. Master page and web.config page of the application
  5. If possible, modify the attached sample and reproduce the issue.
 
Regards, 
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon