Change Radgrid width dynamically to max width

Thread is closed for posting
2 posts, 0 answers
  1. Kishor
    Kishor avatar
    82 posts
    Member since:
    Oct 2012

    Posted 11 Aug 2014 Link to this post

    I want to keep max width of Radgrid to 1200px

    I am adding cloumns dynamically ,

    my requirement is to increase width dynamically as cloumns are added and scrolls when it reach to 1200px


    thanks
    kishor
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2014 in reply to Kishor Link to this post

    Hi Sawan,

    A suggestion is that initially set the width of RadGrid to 0 and set a default HeaderStyle. Then on adding each column increment the width of the RadGrid with the column width till the max limit. You can try as shown below in the sample code snippet:

    C#:
    //Creating RadGrid with following properties
    rgrdSample.Width = Unit.Pixel(0);
    rgrdSample.HeaderStyle.Width = Unit.Pixel(200);
    rgrdSample.MasterTableView.TableLayout = GridTableLayout.Fixed;
    rgrdSample.ClientSettings.Scrolling.UseStaticHeaders = true;
    rgrdSample.ClientSettings.Scrolling.AllowScroll = true;
     
    //On column creation
     static int width = 0;
     
    width = width + Convert.ToInt16(rgrdSample.HeaderStyle.Width.Value);     
    if (width <= 1200)
    {
        rgrdSample.Width = Unit.Pixel(width);
    }      
    GridBoundColumn boundColumn;
    boundColumn = new GridBoundColumn();      
    boundColumn.DataField = "abcd";
    boundColumn.HeaderText ="abcd";
    rgrdSample.MasterTableView.Columns.Add(boundColumn);
    rgrdSample.Rebind();

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top