DataSource
transport: {
read: {
url: crudServiceBaseUrl + "?r=panel/json",
contentType: "application/json",
dataType: "json",
type: "GET"
},
...
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
return kendo.data.transports["odata"].parameterMap(options, operation);
}
...
schema: {
model: {
fields: {
....
date_begin: {
type: "date",
parse: function (value) {
return kendo.toString(new Date(parseInt(value * 1000)), 'yyyy-MM-dd HH:mm:ss');
},
validation: {required: true}
},
....
columns
field
{
field: "date_begin",
width: "120px",
title: "Date Begin",
},
... after update grid
update: {
url: crudServiceBaseUrl + "?r=panel/update",
dataType: "jsonp"
},
it is show me
53291-12-11 17:50:00
i don't know why
any help?
5 Answers, 1 is accepted
Hi,
I have investigated the provided code snippets and I have noticed that you are parsing the value directly to a formatted string. Is it possible for you to only parse the date inside the parse function and format it inside the column declaration as shown in the example below?
https://dojo.telerik.com/oNURoDOR
Let me know if the issue persists.
Kind regards,
Tsvetomir
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi,
Thank you for the clarification. Indeed, when you have set the parse function at the field-level, the function will be executed every time a change in the field is present. Therefore, the date will be multiplied by 1000 several times.
What I can recommend is that you move the parse function to the schema.parse global level and parse the values only once - when the data is loaded. Please take a look at the following Dojo sample demonstrating the same:
https://dojo.telerik.com/OjuPerAf
Regards,
Tsvetomir
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi,
In general, the remote updates could happen by passing a URL to the read/create/update/destroy options. And, the grid would perform the AJAX requests for you and will send the needed data:
https://demos.telerik.com/kendo-ui/grid/editing
Alternatively, you could set up those options to be JavaScript functions as shown in the article below. Within the handlers, you could perform custom AJAX requests and send the needed parameters manually:
https://docs.telerik.com/kendo-ui/framework/datasource/crud#setting-the-local-crud-operations
Let me know if additional details are needed.
Kind regards,
Tsvetomir
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.