11 Answers, 1 is accepted
Please set ItemStyle-HorizontalAlign="Left" and HeaderStyle-HorizontalAlign="Left" for this column.
Greetings,
Dimo
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks for the quick response. I have tired with the properties you have given, its working fine with the header style(left, right and center) and when it comes to itemstyle its always towards the left even if i specify as Center or Right. Is there anything that I doing wrong?
Vinay
Which RadGrid skin are you using? I tried to reproduce the problem, but everything works as expected. Have you by any chance set explicitly some text-align CSS properties for table cells?
If the issue persists, please provide a live URL or paste here your RadGrid declaration.
All the best,
Dimo
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
That works now with the some css change. Now I have a different requirement to set the itemStyle-HorizontalAlignment on prerender(or any other page event) for a column of type integer to be right aligned, could you help me how to access the datasource on the page events?
Thanks,
Vinay
You can try out the following code to check for the DataType of columns in the grid and accordingly set the ItemStyle property for the columns:
cs:
protected void Page_PreRender(object sender, EventArgs e) |
{ |
foreach (GridColumn col in RadGrid1.Columns) |
{ |
if(col.DataType==(System.Type.GetType("System.Int16"))) |
{ |
col.ItemStyle.HorizontalAlign=HorizontalAlign.Right; |
} |
} |
} |
Thanks
Princy.
<ItemStyle HorizontalAlign="Left" Width="120px" />
</telerik:GridBoundColumn>
Here's an example :
<telerik:GridBoundColumn DataField="TotalScore" UniqueName="TotalScore" HeaderText="Epworth Score" >
<ItemStyle HorizontalAlign="Center" Width="120px" />
<HeaderStyle HorizontalAlign="Center" Width="120px" />
</telerik:GridBoundColumn>
Do you have a problem with the mentioned properties? Could you elaborate some more on what you had in mind?
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/how-to/aligning-columns-in-each-level-of-hierarchical-grid
Regards,
Eyup
Telerik
hi...
i am using the below code to align text in center but i am not getting proper output.
the output image is attached..
can u please help me in that
<telerik:RadGrid ID="gvBillOfMaterials" runat="server" AllowPaging="true" PageSize="25"
AllowSorting="True" CellSpacing="0" GridLines="None" ShowGroupPanel="false" AllowFilteringByColumn="false"
ItemStyle-HorizontalAlign="center" HeaderStyle-HorizontalAlign="center"
AutoGenerateColumns="false" >
<MasterTableView UseAllDataFields="true" CommandItemDisplay="Top" TableLayout="Fixed" Width="100%"
AllowFilteringByColumn="false" AllowSorting="true">
<CommandItemTemplate>
In addition to the ItemStyle, you need also to set the property to AlternatingItemStyle as well:
<
MasterTableView
... >
<
AlternatingItemStyle
HorizontalAlign
=
"Center"
/>
That should do the trick.
Regards,
Eyup
Telerik