How to Dynamically Set RadGrid Column Width?

7 posts, 0 answers
  1. Deekshith
    Deekshith avatar
    15 posts
    Member since:
    Mar 2014

    Posted 12 Apr 2014 Link to this post

    Hi All,
    Is their anybody knows how to Dynamically set the RadGrid Column width??
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Apr 2014 in reply to Deekshith Link to this post

    Hi Deekshith,

    You can use the PreRender event of the RadGrid to set the column width of a RadGrid.

    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
      RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").HeaderStyle.Width = Unit.Pixel(100); 
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Deekshith
    Deekshith avatar
    15 posts
    Member since:
    Mar 2014

    Posted 14 Apr 2014 in reply to Princy Link to this post

    Thank You :)
  5. Deekshith
    Deekshith avatar
    15 posts
    Member since:
    Mar 2014

    Posted 21 Apr 2014 Link to this post

    Hi Princy is their any way is their to do the same thing in .aspx?
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Apr 2014 in reply to Deekshith Link to this post

    Hi Deekshith,

    You can set the Width of the column in aspx as follows:

    ASPX:
    <telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="ID">
        <HeaderStyle Width="200px" />
    </telerik:GridBoundColumn>

    Thanks,
    Princy
  7. SABITHA
    SABITHA avatar
    13 posts
    Member since:
    Aug 2013

    Posted 06 Feb 2015 in reply to Princy Link to this post

    In my case the grid has to populate the columns in the conditional basis .  In some cases it will be total of 5 columns and in the other case it will be columns of the total 15columns . Is there any way to set the widhth of all the grid columns to say 100px from the server side code for example say pre-render method.
  8. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 11 Feb 2015 Link to this post

    Hello Sabitha,

    The PreRender event handler is raised a bit late, therefore, you can use the Load or ColumnCreated events if you are using AutogeneratedColumns. In addition, you can check the following approach:
    http://www.telerik.com/help/aspnet-ajax/grid-gridcolumn-resizetofit.html

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017