I have seen same question here: Set the format of a Kendo DateTimePicker date sent to the controller However the given answer doesn't solve my problem.
Briefly: I have a Kendo grid with such column:
model: {
id: "Id",
fields: {
Id: {editable: false, type: "number"},
TransactionAmount: {type: "number"},
TransactionTime: {type: "date"}
}
For the field TransactionTime I have a column defined like this:
{
field: "TransactionTime",
editor: transactionTimeColumnEditor,
format: "{0:u}"
}
The field editor is a DateTimePicker:
function transactionTimeColumnEditor(container, options) {
$('<input name="' + options.field + '" />')
.appendTo(container)
.kendoDateTimePicker({
format: "dd.MM.yyyy HH:mm",
timeFormat: "HH:mm"
});
}
The grid data source transport is defined as following:
create: {
url : "@Html.Raw(Url.Action("AddDeposit", "AdminDeposit"))",
type: "POST",
dataType: "json",
data: addAntiForgeryToken
},
parameterMap: function(data, operation) {
if (operation === "update" || operation === "create") {
data.TransactionTime = kendo.toString(kendo.parseDate(data.TransactionTime, "G"));
}
return data;
}
Controller so far does nothing:
So far my controller does nothing:
[HttpPost]
public ActionResult AddDeposit(DepositTransactionModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();
return new NullJsonResult();
}
In the controller I see the TransactionTime value isn't populated. When I check raw HTTP POST parameters I see such string:
Sun+Jan+22+2017+22:52:39+GMT+0100+(Central+Europe+Standard+Time)
As you can see I tried to convert TransactionTime property of the form data to standard format. However it didn't help. Inside parameterMap function data.TransactionTime looks like this:
Date 2017-01-22T22:03:31.708Z
but HTTP POST param still looks like above.
Also I tried to set Kendo culture:
kendo.culture("@CultureInfo.CurrentCulture.Name");
Result is still same.
I read about another option - setting transport as functions and send manually generated JSON to the server. However I would like to avoid extra complexity on the client side.
Do I miss anything important?