Hi,
I created a datasource and attached the datasource to the Grid. The datasource contains functions for the transport object. When I change a value in my grid, I would expect that the update function is called when I click the Save button in the toolbar. But the update function is not called. Instead for each item in the grid the create function is called.
Code:
$(document).ready(function() {
var data = createRandomData(2);
$("#grid").kendoGrid({
dataSource: {
schema: {
model: {
Id: "Id",
fields: {
Id: { type: "number" },
FirstName: { type: "string" },
LastName: { type: "string" },
City: { type: "string" },
Title: { type: "string" },
BirthDate: { type: "date" },
Age: { type: "number" }
}
}
},
pageSize: 10,
transport: {
read: function(options) {
//alert('read');
//var result = createRandomData(50);
options.success(data);
},
create: function(options) {
alert('create');
//var result = getResult(options);
options.success(data);
},
update: function(options) {
alert('update');
//var result = getResult(options);
options.success(data);
},
destroy: function(options) {
alert('destroy');
//var result = getResult(options);
options.success(data);
},
parameterMap: function(options, operation) {
alert('map');
if (operation !== "read" && options.models) {
//return {models: kendo.stringify(options.models)};
}
}
}
},
toolbar: ["create", "save", "cancel"],
height: 250,
scrollable: true,
sortable: true,
filterable: true,
pageable: true,
editable: true,
batch: false,
columns: [
{
field: "FirstName",
title: "First Name",
width: 100
},
{
field: "LastName",
title: "Last Name",
width: 100
},
{
field: "City",
width: 100
},
{
field: "Title"
},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
},
{
field: "Age",
width: 50
},
{ command: "destroy", title: " ", width: "110px" }
]
});
});
I created a datasource and attached the datasource to the Grid. The datasource contains functions for the transport object. When I change a value in my grid, I would expect that the update function is called when I click the Save button in the toolbar. But the update function is not called. Instead for each item in the grid the create function is called.
Code:
$(document).ready(function() {
var data = createRandomData(2);
$("#grid").kendoGrid({
dataSource: {
schema: {
model: {
Id: "Id",
fields: {
Id: { type: "number" },
FirstName: { type: "string" },
LastName: { type: "string" },
City: { type: "string" },
Title: { type: "string" },
BirthDate: { type: "date" },
Age: { type: "number" }
}
}
},
pageSize: 10,
transport: {
read: function(options) {
//alert('read');
//var result = createRandomData(50);
options.success(data);
},
create: function(options) {
alert('create');
//var result = getResult(options);
options.success(data);
},
update: function(options) {
alert('update');
//var result = getResult(options);
options.success(data);
},
destroy: function(options) {
alert('destroy');
//var result = getResult(options);
options.success(data);
},
parameterMap: function(options, operation) {
alert('map');
if (operation !== "read" && options.models) {
//return {models: kendo.stringify(options.models)};
}
}
}
},
toolbar: ["create", "save", "cancel"],
height: 250,
scrollable: true,
sortable: true,
filterable: true,
pageable: true,
editable: true,
batch: false,
columns: [
{
field: "FirstName",
title: "First Name",
width: 100
},
{
field: "LastName",
title: "Last Name",
width: 100
},
{
field: "City",
width: 100
},
{
field: "Title"
},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
},
{
field: "Age",
width: 50
},
{ command: "destroy", title: " ", width: "110px" }
]
});
});