RadGrid Set Column Width

6 posts, 0 answers
  1. John
    John avatar
    18 posts
    Member since:
    Oct 2010

    Posted 23 Nov 2010 Link to this post

    I am trying to set the column width in the code behind and can not figure out how to do this.  My aspx looks like:


    <
    telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True" runat="server" AutoGenerateColumns="False" GridLines="None" >

     

    <

     

    MasterTableView >

     

     

     

    <Columns>

     

     

     

    <telerik:GridBoundColumn DataField="INVOICE" UniqueName="INVOICE"

     

     

    HeaderText="Invoice">

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    <telerik:GridBoundColumn DataField="DATE" UniqueName="DATE" HeaderText="Date">

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    <telerik:GridBoundColumn DataField="BOL" UniqueName="BOL" HeaderText="BOL">

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    <telerik:GridBoundColumn DataField="PO" UniqueName="PO" HeaderText="PO">

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    <telerik:GridBoundColumn DataField="POHIDE" UniqueName="POHIDE" Visible="false"

     

     

    HeaderText="PO Hide" >

     

     

     

    </telerik:GridBoundColumn>

     

     

     

    </Columns>

     

    </

     

    MasterTableView>

     

     

     

    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="True" >

     

     

     

    <Selecting AllowRowSelect="True" />

     

     

     

    </ClientSettings>

     

     

     

    </telerik:RadGrid>

    I have tried using the RadGrid1_ColumnCreated event but no luck.  How do I change the column width at binding time?

    Thanks

    John

     

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

    Posted 24 Nov 2010 Link to this post

    Hello John,

    You can try the code in the RadGrid PreRender event. The following code snippet will help you to achieve your scenario.

    C#:

    protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
          GridColumn gridCol = RadGrid1.MasterTableView.GetColumn("LastName");
          gridCol.HeaderStyle.Width = Unit.Pixel(100);   
        }


    Thanks,
    Princy.

  3. DevCraft Release
  4. John
    John avatar
    18 posts
    Member since:
    Oct 2010

    Posted 24 Nov 2010 Link to this post

    Thank you very much

  5. Dimo
    Admin
    Dimo avatar
    7505 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2010 Link to this post

    Hi John,

    Please be aware that ColumnCreated is fired only for autogenerated columns.

    All the best,
    Dimo
    the Telerik team

    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 07 Feb 2011 Link to this post

    Thanx.

    It worked nicely..

    Darshan

  7. Rajeev
    Rajeev avatar
    1 posts
    Member since:
    Jul 2011

    Posted 06 Jul 2011 Link to this post

    Post was helpful Thanks!

Back to Top
DevCraft Release