How to set column to auto width

4 posts, 0 answers
  1. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 13 Dec 2010 Link to this post

    I have 4 columns in rad grid and i set the 1st, 3rd, 4th column's width to 150 px (<HeaderStyle Width="150px" /> ),  How can i set the 2nd column's  size to auto fill to ocuppy all the empty space in grid?

    Regards,
    Kenghot.

    Ps. I'm using rad asp.net q3 2009
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 14 Dec 2010 Link to this post

    Hello,

    The described scenario should work across all browsers if TableLayout="Fixed" for the MasterTableView. If you still have problems, please provide your RadGrid declaration.

    All the best,
    Pavlina
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 15 Dec 2010 Link to this post

    My code is as below.


     <telerik:RadGrid ID="grdCart" runat="server" AutoGenerateColumns="False"
        GridLines="None" SkinID="Default">
    <MasterTableView datakeynames="CartDetailKey" TableLayout="Fixed">

        <Columns>
           <telerik:GridTemplateColumn  uniquename="colButton">
               <HeaderStyle Width="200px" />
           <ItemTemplate>
           
             <asp:imagebutton runat="server" ImageUrl="~/images/Temp/save-for-later._V47060936_.gif" id="btnSave" CommandName="Save" Text="Save for later"></asp:imagebutton><br />
             <asp:imagebutton runat="server" ImageUrl="~/images/Temp/delete._V47060447_.gif" id="btnDelete" CommandName="Delete" Text="Delete"></asp:imagebutton>
            
           </ItemTemplate>
           </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn uniquename="colMaterial">
            <HeaderStyle Width="100%" />
            <ItemTemplate>
               <uc1:MaterialObjectUC ID="MaterialObject1" runat="server" />
               <asp:Label ID="lblHidden" runat="server" Visible="false" />
            </ItemTemplate>
            </telerik:GridTemplateColumn>
            
            <telerik:GridTemplateColumn headertext="Qty:" uniquename="colQty">
            <HeaderStyle Width="300px" HorizontalAlign="Right"></HeaderStyle>
            <ItemTemplate><telerik:RadNumericTextBox ID="txbQty" Runat="server" Height="24px"
                    MaxValue="999" MinValue="1" ShowSpinButtons="True" Width="55px" NumberFormat-DecimalDigits="0">
                <DisabledStyle HorizontalAlign="Right" />
                <ReadOnlyStyle HorizontalAlign="Right" />
                <EnabledStyle HorizontalAlign="Right" />
                <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </ItemTemplate>
                <ItemStyle HorizontalAlign="Right" VerticalAlign="Top" />
           </telerik:GridTemplateColumn>

            <telerik:GridTemplateColumn HeaderText="Amount (Baht)" UniqueName="colAmount">
                <EditItemTemplate>
                    <asp:TextBox runat="server"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblAmount" runat="server" Font-Bold="True" ForeColor="#006600"></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="300px" />
                <ItemStyle HorizontalAlign="Right" VerticalAlign="Top" />
            </telerik:GridTemplateColumn>

        </Columns>

    </MasterTableView>
    </telerik:RadGrid>
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Dec 2010 Link to this post

    Hello,

    Please refer to point (4) in the link below:
    http://www.telerik.com/community/forums/aspnet/grid/best-practice-for-grid-and-column-widths.aspx#1214355

    If the RadGrid is used with fixed width and static headers and you set some column widths, it is good to leave one column with no width, so that it can adjust for the cross-browser inconsistency mentioned in the previous point.

    Greetings,
    Pavlina
    the Telerik team
    Browse the vast support resources we have to jump start 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.
Back to Top