Hi,
Am using Kendo mvvm framework to bind my datasource defined in the viewmodel to grid.
Datasource internally calls web api for performing CRUD functions. Am able to get data using datasource transport "read" method. Am having trouble with other methods - update , create and destroy. Below is my datasource from viewModel -
My webapi method for Put -
So when user clicks Save Changes on grid, my webApi PUT method is getting called but the second parameter "value" is not having any records.
Could you please advise on what am missing or point me to an example similar to am doing? Most of the examples I found on internet are using OData. I dont use
Odata.
Thanks
Sai
Am using Kendo mvvm framework to bind my datasource defined in the viewmodel to grid.
Datasource internally calls web api for performing CRUD functions. Am able to get data using datasource transport "read" method. Am having trouble with other methods - update , create and destroy. Below is my datasource from viewModel -
var
salesDataSource =
new
kendo.data.DataSource({
schema: {
data:
function
(data) {
//specify the array that contains the data
return
data || [];
},
errors:
function
(response) {
return
response.error;
},
model: {
id:
"ID"
,
fields: {
ID: { editable:
false
, nullable:
true
},
CompanyName: { validation: { required:
true
} },
LengthOfContract: { editable:
false
},
Status: { editable:
false
}
}
}
},
batch:
true
,
transport: {
read: {
url:
"/api/SalesApi"
,
dataType:
"json"
//
},
update: {
url:
function
(data) {
return
"/api/SalesApi/"
+ data.models[0].ID;
},
dataType:
"json"
,
type:
"PUT"
},
parameterMap:
function
(data, operation) {
if
(operation !=
"read"
) {
console.log(
"here"
);
console.log(data);
return
JSON.stringify({ value: data.models });
}
else
{
return
JSON.stringify(data);
}
}
},
error:
function
(e) {
console.log(
"error"
);
console.log(e);
/*
var message = e.xhr.responseJSON["error"].message.value;
var innerMessage = e.xhr.responseJSON["error"].innererror.message;
alert(message + "\n\n" + innerMessage);
*/
},
serverPaging:
true
,
pageSize: 15
});
// PUT api/sales/5
public
void
Put(
int
id, IEnumerable<SalesModel> value)
{
//do somethig with data
}
So when user clicks Save Changes on grid, my webApi PUT method is getting called but the second parameter "value" is not having any records.
Could you please advise on what am missing or point me to an example similar to am doing? Most of the examples I found on internet are using OData. I dont use
Odata.
Thanks
Sai