I'm trying to align right the text of the numeric columns in a WebHierarchicalDataGrid.
I tried to use the cssClass property of the BoundDataField but it made nothing and i saw another post where somebody suggested the use of an ItemTemplate but the problem is than by doing this i can't use filters.
Is there any other way to achieve this?
Hi fjVazquez,
The correct way to do it is with css classes. However, you need to be sure to have the appropriate selectors. And since you're doing it in the WHDG, you need to apply it to the WHDG column BEFORE the grid view is created. And likewise to a band before a row island is made from that band. Or just do it on the aspx.
this.WHDG1.Columns[0].CssClass = "right";
tbody>tr>td.right
{
text-align : right;
}
regards,David Young
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
David -
This worked great for me. I wanted to post my modified solution as well.
In the WebHierarchicalDataGrid1_InitializeRow event, I modified each columns CssClass property for the column I wanted to right align. I don’t want all the columns right-aligned.
protected void WebHierarchicalDataGrid1_InitializeRow(object sender, RowEventArgs e)
GridRecord oRecord = e.Row;
if (oRecord != null)
oRecord.Items[8].CssClass = "right";
And in the ASPX file I added the following styles. I am using the Office2007Sliver Theme so I just copied what was in the ig_dataGrid.css file and made my addition:
<style type="text/css">
TBODY.igg_Office2007SilverItem > TR > TD.right
text-align: right;
TBODY > TR.igg_Office2007SilverAlt > TD.right
</style>
Anyway, the columns are aligning as I want them to now. Thanks again for your post!