I am getting true/false values from my data and want to implement it as checkbox.

Checked for true and unchecked for false. I using the render function to implement it and then setting checkbox value as T/F for Checked/Unchecked.

However I am always getting unchecked checkbox on my output screen.

How do I link the values T/F to value of the checkbox so it displays properly? Here is my code-->

else if(columnNames[i]=='CheckBoxDemo'){
           columns.push({data: columnNames[i], 
           title: columnNames[i],
           render: function(data, type, row, meta){
               console.log(' checbox value : '+row['CheckBoxDemo']+ ' data '+data);
               return '<input type="checkbox" class="checkbox" value="data">' ;


Here, 'data' has true or false value in it.

  • Did you try {!} around your data value? Something like this: <input type="checkbox" class="checkbox" value="{!data}">. – Shailesh Patil Apr 14 '20 at 6:19
  • You should use the "checked" attribute instead of value in case of the checkbox. Also 'data' is a variable so you should concatenate the return string and use data as the variable. – Avi Rai Apr 14 '20 at 6:58
  • @ShaileshPatil "{!data}" doesn't work too – yash shah Apr 14 '20 at 7:01
  • @AviRai Can you please tell me or post the statement on how to use the checked attribute? – yash shah Apr 14 '20 at 7:02
  • As said above, you have to dynamically add and remove the checked="true" part. So, <input type="checkbox" class="checkbox" checked="true"> will have the checkbox checked and <input type="checkbox" class="checkbox"> will have it unchecked. – Shailesh Patil Apr 14 '20 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.