Hui Zhao
Hui Zhao

Reputation: 675

How to bind the back end data with checkbox?

In the grid, I put a checkbox and a string in a cell together. In the back end I have a bool value to set the checkbox on or off.

Now the question is how to bind it? The following code has the different bool values for each cell. However there is no change.

 <kendo-grid-checkbox-column title="Custom checkbox">
       <ng-template kendoGridCellTemplate let-dataItem let-idx="rowIndex">
         {{dataItem.ProductName}} <input [kendoGridSelectionCheckbox]="idx" [checked]="dataItem.Discontinued"/>
       </ng-template>
     </kendo-grid-checkbox-column>

Please see the demo.

Upvotes: 1

Views: 402

Answers (1)

Sagar Khatri
Sagar Khatri

Reputation: 635

Firstly,

type="checkbox"

is missing and also remove this line (if possible)

[kendoGridSelectionCheckbox]="idx"

It should look like this,

<input type="checkbox" [checked]="dataItem.Discontinued"/>

After doing what's mentioned above, it is working on your stackblitz.

Upvotes: 1

Related Questions