I have a jQuery UI Grid with a .Net MVC Core backend.
The record data has a nullable date in it and everything is displaying fine ( ive added abrdiged working code below)
I use the popup edit to edit the record which contains a nullable date Kendo sends the date as :
Sun May 28 2023 00:00:00 GMT+0100 (British Summer Time)
The Model Binder in MVC does not recognise this as a date and reports a model binding error:
"The value 'Sun May 28 2023 00:00:00 GMT+0100 (British Summer Time)' is not valid for MortgageExpiry."
Theres alot of talk about dates, formats and parsing etc.. in documentation but I'm confused as to what Im actually meant to do.
I know C# dosnt see this as a date when trying to bind it to Model , I understand that but what am I meant to do to fix it.
Can I modify the outgoing format of the date before its sent to server or is there something else I should be doing?
function populateProductsTable() {
var applicationId = $("#MortgageApplicationId").val();
var gridDataSource = new kendo.data.DataSource({
type: "json",
transport: {
read: {
url: "/api/ApplicationProductsApi/Read/" + applicationId,
dataType: "json"
},
create: {
url: "/api/ApplicationProductsApi/Create",
dataType: "json",
type: "POST"
},
update: {
url: "/api/ApplicationProductsApi/Update",
dataType: "json",
type: "POST"
},
destroy: {
url: "/api/ApplicationProductsApi/Delete",
dataType: "json",
type: "POST"
},
},
schema: {
data: "data",
total: "total",
errors: "errors",
model: {
id: "id",
fields: {
id: { type: "number", editable: false },
productProvider: { type: "string", validation: { required: true } },
productTypeId: {type: "number", validation: { required: true } },
productName: { type: "string" },
mortgageExpiry: { type: "date" },
}
}
}
});
/* eslint-enable */
$("#productGrid").kendoGrid({
toolbar: ["create"],
editable: "popup",
dataSource: gridDataSource,
filterable: true,
sortable: true,
pageable: false,
columns: [{
command: ["edit"], title: " ",
}, {
field: "id",
filterable: false,
hidden: true,
}, {
field: "productProvider",
title: "Provider"
}, {
field: "productTypeId",
title: "Type",
editor: dropDownProductType, template: "#=productTypeIdName#"
}, {
field: "productName",
title: "Name"
},{
field: "mortgageExpiry",
title: "Expiry",
format: "{0:dd/MMM/yyyy}"
},
]
});
}
Sat May 27 2023 00:00:00 GMT+0100 (British Summer Time)
Sat May 27 2023 00:00:00 GMT+0100 (British Summer Time)
Hi Brendan,
You can use the transport.parameterMap to modify the request parameters to a format suitable for the remote service. By default, the data source sends the parameters using jQuery conventions. More information you can find in the below API documentation:
https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.parametermap
Please let me know if this helps.
Regards,
Nikolay