For the life of me, I can not figure out why this is happening.
Below I have a pretty simple grid wired to a Read and a Destroy event. The Read works. If I press delete and then save the grid the wrong webservice is called.
If batch editing it turned on then when I press save the READ event is called (instead of the Destroy event). And I get the error that I can't stuff an enumeriable list of objects into the ID field of the Read service.
If batch editing is turned off then the CREATE event is called! And since I haven't created one I get a 404.
That's weird man. Any ideas?
Below I have a pretty simple grid wired to a Read and a Destroy event. The Read works. If I press delete and then save the grid the wrong webservice is called.
If batch editing it turned on then when I press save the READ event is called (instead of the Destroy event). And I get the error that I can't stuff an enumeriable list of objects into the ID field of the Read service.
If batch editing is turned off then the CREATE event is called! And since I haven't created one I get a 404.
That's weird man. Any ideas?
$(
"#JobAttachments"
).kendoGrid({
columns: [
{ title:
"Filename"
, template:
"<a href='../UploadedFiles/${ SavedFileName }'>${ OriginalFileName }</a>"
, width:
"250px"
},
{ field:
"EnterBy"
, title:
"Uploaded By"
, width:
"200px"
},
{ command:
"destroy"
, title:
"Delete"
, width:
"100px"
}
],
toolbar: [
"save"
,
"cancel"
],
// specify toolbar commands
editable:
true
,
// enable editing
dataSource: {
schema: {
data:
"d"
,
// ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
model: {
// define the model of the data source. Required for validation and property types.
id:
"JobTaskId"
,
fields: {
AttachmentID: { editable:
false
, nullable:
false
},
JobId: { editable:
false
, nullable:
false
},
OriginalFileName: { editable:
false
},
SavedFileName: { editable:
false
},
AttachmentType: { },
Notes: { },
EnterBy: {}
//,
//EnterDate: { type: "date"}
}
}
},
batch:
false
,
// enable batch editing - changes will be saved when the user clicks the "Save changes" button
transport: {
create: {
url:
"../WebServices/JobAttachmentWebservice.asmx/NotUsed"
,
contentType:
"application/json; charset=utf-8"
,
// tells the web service to serialize JSON
type:
"POST"
//use HTTP POST request as the default GET is not allowed for ASMX
},
read: {
url:
"../WebServices/JobAttachmentWebservice.asmx/Read"
,
contentType:
"application/json; charset=utf-8"
,
// tells the web service to serialize JSON
type:
"POST"
//use HTTP POST request as the default GET is not allowed for ASMX
},
update: {
url:
"../WebServices/JobAttachmentWebservice.asmx/Update"
,
contentType:
"application/json; charset=utf-8"
,
// tells the web service to serialize JSON
type:
"POST"
//use HTTP POST request as the default GET is not allowed for ASMX
},
destroy: {
url:
"../WebServices/JobAttachmentWebservice.asmx/Delete"
,
contentType:
"application/json; charset=utf-8"
,
// tells the web service to serialize JSON
type:
"POST"
//use HTTP POST request as the default GET is not allowed for ASMX
},
parameterMap:
function
(data, operation) {
if
(operation !=
"read"
) {
// web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
return
JSON.stringify({ jobView: data.models })
}
else
{
return
JSON.stringify({ JobId: currentJobId })
}
}
}
}
});