This is a migrated thread and some comments may be shown as answers.
Dates not sorting correctly in Grid
5 Answers 48 Views
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 05 Sep 2017, 09:28 PM

Date is not sorting correctly in my grid. It seems that older dates than 2000 are not sorting correctly. In the database, the data type is datetime2. 

Here is the code for the grid:

    $("#reportsGridIn").kendoGrid({
        selectable: "multiple",
        sortable: {
            allowUnsort: false,
            initialDirection: "asc"
        },
        schema: {
            model: {
                fields: {
                    transDate: { type: "date" }
                }
            }
        },
        columns: [
          { field: "id", hidden: true },
          { field: "corporationName", title: "Corporation", width: 20 },
          { field: "transDate", title: "Trans Date", width: 18, template: "#= kendo.toString(new Date(parseInt(transDate.substr(6))),'MM/dd/yyyy')#", type: "date" },
          { field: "headline", title: "Headline", width: 38 },
          { field: "marketScope", title: "Market Scope", width: 25 }
        ]
    });

Thanks,

Mike

5 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 05 Sep 2017, 09:32 PM
Here's a screen shot of dates in the grid not sorting.
0
Mike
Top achievements
Rank 1
answered on 05 Sep 2017, 09:34 PM
Let my try that again. Here's a screen shot.
0
Mike
Top achievements
Rank 1
answered on 05 Sep 2017, 09:35 PM
I'm not able to attach the screen shot. The site give me an error. 
0
Stefan
Telerik team
answered on 07 Sep 2017, 10:11 AM
Hello Mike,

Thank you for the provided code, as for the screenshot I can assume that there was a server issue at that moment. If needed, the screenshot can be hosted on a third party service and we can access the link.

I used one of our demos with dates, and they are sorted as expected if they are before 2000:

http://demos.telerik.com/kendo-ui/grid/remote-data-binding

Also, in the code snippet, the schema is set in the Grid configurations, but it has to be in the dataSource configuration as otherwise, it will handle the dates as strings. If this was just shortened in order to reduce the code, please disregard this part.

Still, if the date format is specific, please send an example of 4 - 5 data records in the format sent from the server and I will gladly investigate further.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mike
Top achievements
Rank 1
answered on 07 Sep 2017, 04:36 PM
I followed the example you've provided, specifically, I defined the fields in the data source, as shown in the example. That fixed the issue. Thanks!
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or