DataSource dates

1 Answer 17 Views
Grid
CHRISTOPHER
Top achievements
Rank 1
Iron
Iron
CHRISTOPHER asked on 19 May 2025, 01:53 PM

I've seen your demos on setting up the type: "date" and the format: stuff on the model and on the column display for the grid.  Your demo sorts the dates as if they are dates properly.  Ours shows the value as null if we set the type to date.  It displays the string properly if we set it to type string but still sorts as a string.  If we simply set the column to the kendo format and do not use a schema on the datasource, our code still sorts as a string.

https://dojo.telerik.com/TgCibbiL

When I looked at the data in your demo, it looks like the long form GMT.  Today, we are instead blocking the script from sending the .NET property types of DateTime and instead sending a pre-formatted string of the date.  Ran into some serialization issues when posting those same objects with DateTime properties on them.

Are you returning your DateTime properties as strings but formatted in this GMT when you serialize your .NET data objects back to the JavaScript handlers?

Jay
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 21 May 2025, 06:38 PM

I am not sure what you mean by 'setting up the type: "date"'. I do not see that in the dojo you posted. We use models with the type DateTime? all the time when populating our grids and haven't run into any issues. I don't know if it matters, but most of our grids get populated as JsonResults, like
    public class ListModel
    {
        public int? Count { get; set; }
        public DateTime? FirstDate { get; set; }
        public DateTime? SecondDate { get; set; }
    }

    public JsonResult _DetailsGrid([DataSourceRequest] DataSourceRequest request)
    {
        ListModel list = Service.GetList();
        DataSourceResult result = list.ToDataSourceResult(request);
        return Json(result);
    }

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 22 May 2025, 11:22 AM

Hello, Christopher,

Based on the information provided so far, I am not sure I understand the issue you are experiencing. If we use our Remote Data Binding demo for reference, the OrderDate comes in the following format from the server - OrderDate: "/Date(1593820800000)/", and setting type: "date" in the schema.model displays the data as you see it. If you are interested, you can check the service used by the demo on this link.

Kindly elaborate a bit more around the issue you are experiencing, so that I can provide further details and assistance.

Looking forward to your reply.

Regards,
Martin
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.

CHRISTOPHER
Top achievements
Rank 1
Iron
Iron
commented on 02 Jun 2025, 06:34 PM

If C# were your server side language, what is the .NET type for OrderDate? If you are converting it to a string, how are your doing it server side.

We are transmitting the string as MM/dd/yyyy and I don't think the grid is able to properly sort the date with that value.  It is an issue on our end, I am just trying to figure what I need to do differently on the server.

Martin
Telerik team
commented on 05 Jun 2025, 11:13 AM

You can see the definition for the Orders model on this link. You can see that the type is DateTime. You can also see in the controller's implementation I shared in my previous reply that we do not do anything specific with the OrderDate field. I will be glad to help if you could provide a runnable test example where I can see any issues you are experiencing.
Tags
Grid
Asked by
CHRISTOPHER
Top achievements
Rank 1
Iron
Iron
Answers by
Martin
Telerik team
Share this question
or