KendoUI Grid Cell formatting


This is part of a much more complex set of KendoUI Grid Widget configuration. For reading the whole tutorial read this.

Format column

You might use template for formatting columns in your KendoUI grid as in here. But for easy formatting as numbers, currency, dates I do prefer to use format that is much simpler.

$("#grid").kendoGrid({
    dataSource:{
        data:[
            { "Name":"John", "BirthDate":new Date(1965, 0, 1)},
            { "Name":"Jane", "BirthDate":new Date(1964, 0, 1)},
            { "Name":"Jeff", "BirthDate":new Date(1963, 0, 1)},
            { "Name":"Jack", "BirthDate":new Date(1962, 0, 1)}
        ],
        pageSize:5
    },
    columns:[
        {
            field:"Name"
        },
        {
            field:"BirthDate",
            title:"Birth Date (Template)",
            template:'#= kendo.toString(BirthDate,"dd MMMM yyyy") #'
        },
        {
            field:"BirthDate",
            title:"Birth Date (format)",
            format:'{0:dd MMMM yyyy}'
        }
    ]
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s