or

this.get("name")<input type="text" data-value-update="keyup" data-bind="value: searchText, events: { keyup: searchForItem }" />//app is global
app.viewmodels.carsViewModel.get("cars").push(car);<div id="carsView" data-role="view" data-model="app.viewmodels.carsViewModel">When I set the toolbar to display a delete button, nothing happens when I click on it.
But it works when I add a destroy column. Should I do something special to active the delete button in toolbar?
here is my code:
$("#grid").kendoGrid({ dataSource: _ds, height: 350, scrollable: false, pageable: true, sortable: false, //selectable: "multiple, row", navigatable: true, columns: [ //{title: "Id", field: "Id", width: 150}, {title: "Name", field: "Name", width: 150}, {title: "Description", field: "Description", width: 300} ], toolbar: ["create", "destroy", "save", "cancel"], editable: true });_ds = new kendo.data.DataSource({ type: "json", serverPaging: true, serverSorting: true, pageSize: 15, batch: false, transport: { read: { url: "@Url.Action("GetRoles", "Role", new { area = "UserManagement"})" }, update: { url: "@Url.Action("UpdateRole", "Role", new { area = "UserManagement" })" }, destroy: { url: "@Url.Action("DeleteRole", "Role", new { area = "UserManagement" })" }, create: { url: "@Url.Action("CreateRole", "Role", new { area = "UserManagement" })" } }, schema: { data: function(data) { return data.result; }, total: function(data) { return data.totalCount; }, model: { id: "Id", fields: { Id: { editable: false, nullable: false }, Name: { editable: true, validation: { required: true } }, Description: { editable: true, validation: { required: false } } } } }, error: function (e) { var json = jQuery.parseJSON(e.responseText); alert("An error has occured: " + json.Message); } });function GetContactDS(){ var MyModel = kendo.data.Model.define({ id: "ID", fields: { __KEY: { type: "string" }, __STAMP: { type: "number" }, ID: { editable: false, nullable: true }, firstName: { type: "string" }, middleName: { type: "string" }, lastName: { type: "string" } }, }); var crudServiceBaseUrl = "http://127.0.0.1:8081/cors/Contact"; var MyDataSource = new kendo.data.DataSource({ transport: { read: function(options) { $.ajax( {
url: crudServiceBaseUrl + '/?$expand=ContactType', dataType: "json", data: options.data,
success: function(result) { options.success(result);
} }); }, update: function(options) { $.ajax( {
url: crudServiceBaseUrl + "/?$method=update", type: "POST", dataType: "json", data: kendo.stringify(options.data.models), success: function(result) { // notify the DataSource that the operation is complete options.success(result); } }); }, destroy: { url: crudServiceBaseUrl + "/?$method=delete", type: "GET" }, create: { url: crudServiceBaseUrl + "/?$method=update", dataType: "json", type: "POST" }, parameterMap: function(options, operation) { if (operation !== "read" && options.models) { return JSON.stringify({"__ENTITIES": options.models}); } } }, batch: true, pageSize: 30, schema: { model: MyModel, data: "__ENTITIES" } }); return MyDataSource;}{"__entityModel":"Contact","__COUNT":1,"__SENT":1,"__FIRST":0,"__ENTITIES":[{"__KEY":"7","__STAMP":9,"ID":7,"firstName":"jay","middleName":"a","lastName":"blue","ContactType":{"__KEY":"2","__STAMP":4,"ID":2,"name":"Home","contactCollection":{"__deferred":{"uri":"/rest/ContactType(2)/contactCollection?$expand=contactCollection"}}}}]}var ContactDS = GetContactDS(); $("#grid").kendoGrid({ selectable: "row", filterable: true, pageable: true, sortable: true, change: function(){ datamodel = this.dataItem(this.select()); ID = datamodel.ID }, dataSource: ContactDS, columns: [ { field: "ID" }, { field: "firstName" }, { field: "middleName" }, { field: "lastName" }, {field: "ContactType.name"} ] });$("#update").click(function () { datamodel.set("firstName", $("#firstName").val()); datamodel.set("lastName", $("#lastName").val()); datamodel.set("middleName", $("#middleName").val()); // datamodel.set("ContactType.__KEY",3); ContactDS.sync();{ "__ENTITIES": [{"__KEY":"7","__STAMP":14,"firstName":"jay","middleName":"a","lastName":"red","ContactType":{"__KEY":"2"}}]}[{"__KEY":"7","__STAMP":12,"ID":7,"firstName":"jay","middleName":"a","lastName":"blue","ContactType":{"__KEY":"3","__STAMP":2,"ID":3,"name":"Work","contactCollection":{"__deferred":{"uri":"/rest/ContactType(3)/contactCollection?$expand=contactCollection"}}}}]{ "__ENTITIES":}
Widgets may configured in the following two (2) ways: