Using a Kendo Grid to do inline editing. It works absolutely great and love everything Kendo brings to the table. I'm working on doing some refactoring and trying to remove as much duplicate code from an application because ... well because it needs to happen. :-)
So I'm curious, is there a way to specify default values for transport. For example, below you can see a Read, Update, Destroy and in each case I have to set the content type, send auth tokens in the header, etc.
Thanks,
Richard
transport: {
// eslint-disable-next-line consistent-return
parameterMap:
function
(data, type) {
if
(type !==
"read"
&& data) {
return
kendo.stringify(data);
}
},
read: {
url:
"https://api.domain.com/Billings/"
,
dataType:
"json"
,
beforeSend:
function
(xhr) {
xhr.setRequestHeader(
"TOKEN"
, "SomethingHere");
xhr.setRequestHeader(
"SECRET"
,
"SomethingHere"
);
}
},
update: {
type:
"PUT"
,
url:
"https://api.domain.com/Billing"
,
dataType:
"json"
,
contentType:
"application/json;charset=utf-8"
,
beforeSend:
function
(xhr) {
xhr.setRequestHeader(
"TOKEN"
, "SomethingHere");
xhr.setRequestHeader(
"SECRET"
,
"SomethingHere"
);
}
},
destroy: {
type:
"DELETE"
,
url:
"https://api.domain.com/Billing"
,
dataType:
"json"
,
contentType:
"application/json;charset=utf-8"
,
beforeSend:
function
(xhr) {
xhr.setRequestHeader(
"TOKEN"
, "SomethingHere");
xhr.setRequestHeader(
"SECRET"
,
"SomethingHere"
);
}
}
},