I am trying to add a Delete button to each row in my kendo grid. I added the destroy command to the grid configuration and have the Delete button showing, but when I click it, I receive a console error -- Uncaught TypeError: Cannot read property 'results' of undefined. This is referring to a line in the schema.parse that reads:
for (var i = 0, il = response.d.results.length; i < il; i++)
It's saying response is undefined. when I console.log(response) and it turns out that the entire html page is being sent in the response.
This doesn't make sense to me, because when I console.log(options) in transport.destroy and console.log(data) in the parameterMap, both console.logs show me in JSON format the row that needs to be deleted and includes the ID.
So why is it being transported to the schema as the entire html page? console.log(response) in the schema starts with <DOCTYPE !HTML> etc. and includes the whole page. Can anyone tell me why this is?
and yes, I have already included editable: "inline" in the grid configuration. Thanks
var ds = new kendo.data.DataSource({
transport: {
read: {
url: function () {
***omitted for privacy, but read works. the grid loads fine***
},
cache: false,
type: 'GET',
headers: {
'Accept': 'application/json; odata=verbose'
}
},
destroy: {
url: function (options) {
console.log(options);
console.log("destroy command called");
}
},
parameterMap: function (data, type) {
console.log(data);
console.log(type);
if (type == "destroy") {
// send the destroyed data items as the "models" service parameter encoded in JSON
return { models: kendo.stringify(data.models) }
}
}
},
pageSize: 10,
sort: {
field: "Modified",
dir: "desc"
},
filter: {
logic: 'and',
filters: [{
field: 'State',
operator: 'eq',
value: 'Submitted'
}]
},
error: function (e) {
kendo.alert(e.errors);
},
schema: {
errors: "error",
parse: function (response) {
console.log(response);
var data = [];
for (var i = 0, il = response.d.results.length; i < il; i++) {
var item = response.d.results[i];
//Create new fields to handle filtering by Date (instead of DateTime)
item.ModifiedFilter = new Date(new Date(item.Modified).setHours(0, 0, 0, 0));
item.CreatedFilter = new Date(new Date(item.Created).setHours(0, 0, 0, 0));
data.push(item);
}
return data;
},
total: function (response) {
return response.length;
},
model: {
id: 'Id',
fields: {
```