Reputation: 143
I am using kendo grid. All my column headers are left aligned. I want the column headers having numeric data to be right aligned.Can anyone suggest anything ?
Upvotes: 3
Views: 8663
Reputation: 1207
There's already a configuration setting for that. columns.headerAttributes
Upvotes: 4
Reputation: 21465
You can try using columns.headerTemplate
property:
headerTemplate: kendo.template("<div class='header-right'>ColumnName</div>")
With header-right
being:
.header-right {
text-align: right
}
Cons:
UPDATE
Found simple way of doing this with the following function:
var tmpl = function() {
return kendo.template($("#javascriptTemplate").html())({ columnName: this.toString() });
};
This function just calls kendo.template
and returns its results, passing an object to it with the column's name. It is used in the columns
property like this:
{ field: "age", headerTemplate: tmpl.bind("Age") }
It becomes more elegant and readable in my opinion, and actually doens't differ so much from the common way to set the column title, as it would be set as title: "Age"
after all.
And the template:
<script id="javascriptTemplate" type="text/x-kendo-template">
<div class='header-right'>#:columnName#</div>
</script>
Upvotes: 1
Reputation: 1703
Try this one
#my-grid .k-grid-header .k-header {
text-align: right;
}
Upvotes: 0