Dear Community,
Below are the details of items I have on my page:
I have a DIV on my page:
My code
The Problem
The challenge we are facing is in IsActive column. As you can see that I'm using a template for this column to show check-box in UI instead of regular column. Whenever, I change the selection of my check-box, it just gets reflected on UI but doesn't update the viewmodel (it should have as it is an observable data source).
If I remove the template from this column then change in checkbox changes the viewmodel. I want my viewmodel to update as per changes made in UI in my scenario.
Please share your comments.
Best Regards,
Shiva
Below are the details of items I have on my page:
I have a DIV on my page:
<div id="grid" />My code
var viewModel = kendo.observable({ gridSource: [ { FirstName: "Shiva", LastName: "Wahi", City: "Delhi", Title: "Module Lead", BirthDate: "10/29/1984", Age: 27, IsMarried: "N", IsActive: true }, { FirstName: "Priya", LastName: "Srivastava", City: "Noida", Title: "Tech Lead", BirthDate: "08/19/1982", Age: 30, IsMarried: "Y", IsActive: false } ] }); function IsMarriedConverter(status) { if (status == "Y") return "Married"; else return "Un-Married"; } $(document).ready(function () { $("#grid").kendoGrid({ dataSource: { data: viewModel.gridSource, schema: { model: { fields: { FirstName: { type: "string" }, LastName: { type: "string" }, City: { type: "string" }, Title: { type: "string" }, BirthDate: { type: "date" }, Age: { type: "number" }, IsMarried: { type: "string", editable: false }, IsActive: { type: "boolean" } } } }, pageSize: 10 }, width: 500, height: 250, editable: true, groupable: true, scrollable: true, sortable: true, filterable: true, pageable: true, toolbar: ["create", "save", "cancel"], columns: [ { field: "FirstName", title: "First Name", width: 75 }, { field: "LastName", title: "Last Name", width: 75 }, { field: "City", width: 75 }, { field: "Title", width: 75 }, { field: "BirthDate", title: "Birth Date", width: 75, template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #' }, { field: "Age", width: 50 }, { field: "IsMarried", width: 50, template: '#= IsMarriedConverter(IsMarried) #' // Value converter }, { field: "IsActive", width: 50, template: '<input type="checkbox" #= IsActive ? checked="checked" : "" # />' // Creating checkbox column } ] }); });The Problem
The challenge we are facing is in IsActive column. As you can see that I'm using a template for this column to show check-box in UI instead of regular column. Whenever, I change the selection of my check-box, it just gets reflected on UI but doesn't update the viewmodel (it should have as it is an observable data source).
If I remove the template from this column then change in checkbox changes the viewmodel. I want my viewmodel to update as per changes made in UI in my scenario.
Please share your comments.
Best Regards,
Shiva