This is a migrated thread and some comments may be shown as answers.

radGrid column alignment

11 Answers 2995 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vinay
Top achievements
Rank 1
vinay asked on 27 Oct 2008, 08:43 PM
Hi

I have a requirement to align a column on the grid to the left. How can I do that, any suggestion?

Thanks
Vinay

11 Answers, 1 is accepted

Sort by
1
Dimo
Telerik team
answered on 27 Oct 2008, 09:17 PM
Hello Vinay,

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.
0
vinay
Top achievements
Rank 1
answered on 27 Oct 2008, 09:42 PM
Hi Dimo,

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
0
Dimo
Telerik team
answered on 27 Oct 2008, 10:05 PM
Hi 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.
0
vinay
Top achievements
Rank 1
answered on 28 Oct 2008, 09:15 PM
Hi Dimo,

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
0
Accepted
Princy
Top achievements
Rank 2
answered on 29 Oct 2008, 07:22 AM
Hello 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.
0
Sk
Top achievements
Rank 1
answered on 18 May 2013, 05:56 AM
<telerik:GridBoundColumn DataField="StoreNumber" HeaderText="Store #">
                                            <ItemStyle HorizontalAlign="Left" Width="120px" />
                                        </telerik:GridBoundColumn>
0
Salim
Top achievements
Rank 1
answered on 23 Nov 2015, 10:30 PM

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>
           

0
Eyup
Telerik team
answered on 26 Nov 2015, 02:33 PM
Hello Salim,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sandeep
Top achievements
Rank 1
answered on 10 Feb 2016, 01:44 PM

hi 

        ItemStyle-HorizontalAlign="center"  & HeaderStyle-HorizontalAlign="center" 
   
 

i am using the above code but the output is not proper.

can you plz help me out?

i have attached the output which i got

0
Sandeep
Top achievements
Rank 1
answered on 10 Feb 2016, 01:51 PM

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>

 

 
0
Eyup
Telerik team
answered on 15 Feb 2016, 09:22 AM
Hi Sandeep,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
vinay
Top achievements
Rank 1
Answers by
Dimo
Telerik team
vinay
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sk
Top achievements
Rank 1
Salim
Top achievements
Rank 1
Eyup
Telerik team
Sandeep
Top achievements
Rank 1
Share this question
or