Hello,
In some demos & examples I found this : "stringifyDates": true in the data source configuration,
but didn't find anything in the documentation about this. (looks like a secret settings option Telerik uses on their demos ;-)
is somebody has a documentation about this "stringifyDates": true ?
another thing on same subject, I try to use the parameterMap , to parse the model sent to the server,
and stringify the date in the model "SupplyDate": { "type": "date" }, but its never called!
please see example here.
var
ds =
new
kendo.data.DataSource({
"type"
: (
function
() {
if
(kendo.data.transports[
'aspnetmvc-ajax'
]) {
return
'aspnetmvc-ajax'
; }
else
{
throw
new
Error(
'The kendo.aspnetmvc.min.js script is not included.'
); } })(),
"transport"
: {
"read"
: {
"url"
:
'/Controller/Products_Get'
,
"data"
:
function
() {
return
{
"OrderNumber"
:
"0001"
};
},
"complete"
:
function
(jqXHR, textStatus) {
if
(textStatus ==
"error"
) {
var
msg =
"read event completed with error. invalid url or other javascript error"
;
console.log(msg);
}
else
{
var
result = JSON.parse(jqXHR.responseText);
console.log(
"jqXHR.responseText:\n"
+ jqXHR.responseText,
'#ffffff'
,
'#0011cc'
);
}
}
},
"update"
: {
"//type"
:
"POST"
,
//"dataType": "json",
//"contentType": "application/json",
"url"
:
'/Controller/Product_Upsert'
,
"complete"
:
function
(jqXHR, textStatus) {
Parse_UpsertOrDelete_Complete(
"update"
, jqXHR, textStatus);
}
},
"create"
: {
//"type": "POST",
//"dataType": "json",
//"contentType": "application/json",
"url"
:
'/Controller/Product_Upsert'
,
"complete"
:
function
(jqXHR, textStatus) {
Parse_UpsertOrDelete_Complete(
"create"
, jqXHR, textStatus);
}
},
"destroy"
: {
//"type": "POST",
//"dataType": "json",
//"contentType": "application/json",
"url"
:
'/Controller/Product_Delete'
,
"complete"
:
function
(jqXHR, textStatus) {
Parse_UpsertOrDelete_Complete(
"destroy"
, jqXHR, textStatus);
}
},
"stringifyDates"
:
true,
"prefix"
:
""
,
"parameterMap"
:
function
(data, operation) {
console.log(
"operation: "
+ operation +
" data: "
+ JSON.stringify(data));
if
(operation ===
"update"
|| operation ===
"create"
|| operation ===
"destroy"
) {
return
JSON.stringify({ entity: data });
}
return
data;
}
},
"pageSize"
: 1000,
"page"
: 1,
"total"
: 0,
"serverPaging"
:
true
,
"serverSorting"
:
true
,
"serverFiltering"
:
true
,
"serverGrouping"
:
true
,
"serverAggregates"
:
true
,
"filter"
: [],
"error"
:
function
(jqXHR) {
console.log(
"jqXHR.status ="
+ jqXHR.status);
},
"schema"
: {
"data"
:
"Data"
,
"total"
:
"Total"
,
"errors"
:
"Errors"
,
"model"
: {
"id"
:
"ProductionOrderNumber"
,
"fields"
: {
"OrderNumber"
: {
"type"
:
"number"
},
"SupplyDate"
: {
"type"
:
"date"
},
"CustomerName"
: {
"type"
:
"string"
},
"Units"
: {
"type"
:
"number"
}
}
}
}
});
function Parse_UpsertOrDelete_Complete(action, jqXHR, textStatus) {
// handle complete...
}
Controller
class
ProductEntity {
public
int
OrderNumber {
get
;
set
;}
public
DateTime SupplyDate {
get
;
set
;}
public
string
CustomerName {
get
;
set
;}
public
int
Units {
get
;
set
;}
}
[AcceptVerbs(HttpVerbs.Post)]
public
async Task<ActionResult> Product_Upsert([DataSourceRequest]DataSourceRequest request,
ProductEntity entity)
{
ProductEntity product = entity;
// product.SupplyDate not set correctly when not using
// ( "stringifyDates": true in the DataSource )
}
Thanks !