radGrid column alignment

12 posts, 1 answers
  1. vinay
    vinay avatar
    6 posts
    Member since:
    Jun 2008

    Posted 27 Oct 2008 Link to this post

    Hi

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

    Thanks
    Vinay
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 27 Oct 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. vinay
    vinay avatar
    6 posts
    Member since:
    Jun 2008

    Posted 27 Oct 2008 Link to this post

    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
  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 27 Oct 2008 Link to this post

    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.
  6. vinay
    vinay avatar
    6 posts
    Member since:
    Jun 2008

    Posted 28 Oct 2008 Link to this post

    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
  7. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Oct 2008 Link to this post

    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.
  8. Sk
    Sk avatar
    9 posts
    Member since:
    May 2013

    Posted 18 May 2013 Link to this post

    <telerik:GridBoundColumn DataField="StoreNumber" HeaderText="Store #">
                                                <ItemStyle HorizontalAlign="Left" Width="120px" />
                                            </telerik:GridBoundColumn>
  9. Salim
    Salim avatar
    10 posts
    Member since:
    Apr 2012

    Posted 23 Nov 2015 Link to this post

    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>
               

  10. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 26 Nov 2015 Link to this post

    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
  11. Sandeep
    Sandeep avatar
    2 posts
    Member since:
    Feb 2016

    Posted 10 Feb in reply to Dimo Link to this post

    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

  12. Sandeep
    Sandeep avatar
    2 posts
    Member since:
    Feb 2016

    Posted 10 Feb Link to this post

    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>

     

     
  13. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 15 Feb Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017