Shaul Behr
Shaul Behr

Reputation: 38003

Why is formatting my KendoGrid columns not working?

I'm learning Kendo UI, and following one of the walkthroughs. I've got a grid working, but the date formatting is not working, for some reason.

$("#archiveGrid").kendoGrid({
    columns: [
        { field: "SentDate", title: "Sent", format: "{0:MM/dd/yyyy}" },
        { field: "SenderName", title: "Sender" },
        { field: "SenderEmail", title: "Email" },
        "Subject"
    ],
    dataSource: new kendo.data.DataSource({
        transport: {
            read: "api/messages"
        },
        pageSize: 15,
        serverPaging: true,
        schema: {
            data: "Data",
            total: "Count"
        }
    }),
    pageable: true
});

But my dates still come out looking like 2014-02-07T21:06:03.993. I tested the theory that the grid is ignoring the format property and changed the format string to "foo {0:MM/dd/yyyy}", which made the dates appear as foo 2014-02-07T21:06:03.993.

So what am I doing wrong?

Upvotes: 0

Views: 581

Answers (1)

Anto Subash
Anto Subash

Reputation: 3215

You are missing the model in DataSource. try adding a proper model and set the type as date. then the format will work properly and also don't forget to mention the id.

schema: {
                id: "Id",
                data: "Data",
                total: "Count",
                fields: {
                        SentDate: { editable: true, type: "date"},
                        SenderName: { editable: true},
                        SenderName: { editable: true}
                    }
            }

Upvotes: 1

Related Questions