KendoUI Grid Cell right aligned


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

Align Cells to the right

KendoUI documentation uses to recommend to use templates for this kind of customization but I tend to prefer adding to the columns a definition of attributes: { style:”text-align: right;”} or define a CSS style ob-right as text-align: right and then attributes into columns as attributes: { class:”ob-right”}.

Example:

<div id="numbers_tbl"></div>
.ob-right {
    text-align: right;
}
$("#numbers_tbl").kendoGrid({
    dataSource:{
        data:[
            {value: 10.00},
            {value: 10.01},
            {value: 10.02},
            {value: 10.03}
        ],
        pageSize:10
    },
    columns:[
        { field:"value", title:"default" },
        { field:"value", title:"right", attributes:{ class:"ob-right" } }
    ]
}).data("kendoGrid");​

NOTE: I have displayed the same column twice, once titled “default” with the default alignment and the second titled “right” with right alignment.

You can see this working here.

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