This is a migrated thread and some comments may be shown as answers.

grid unix timestamp to date wrong

5 Answers 23 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
whythisname
Top achievements
Rank 1
whythisname asked on 16 Apr 2021, 12:01 AM

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

Sort by
0
Tsvetomir
Telerik team
answered on 20 Apr 2021, 09:28 AM

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.

0
whythisname
Top achievements
Rank 1
answered on 20 Apr 2021, 10:05 AM
date wrong after save in datepicker
0
Tsvetomir
Telerik team
answered on 23 Apr 2021, 08:20 AM

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.

0
whythisname
Top achievements
Rank 1
answered on 23 Apr 2021, 06:36 PM
how to remote update items? 
0
Tsvetomir
Telerik team
answered on 28 Apr 2021, 09:41 AM

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.

Tags
Date/Time Pickers
Asked by
whythisname
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
whythisname
Top achievements
Rank 1
Share this question
or