This is a migrated thread and some comments may be shown as answers.

How to set column to auto width

3 Answers 528 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kenghot
Top achievements
Rank 1
kenghot asked on 13 Dec 2010, 12:00 PM
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

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 14 Dec 2010, 04:39 PM
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.
0
kenghot
Top achievements
Rank 1
answered on 15 Dec 2010, 12:02 PM
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>
0
Pavlina
Telerik team
answered on 20 Dec 2010, 02:37 PM
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.
Tags
Grid
Asked by
kenghot
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
kenghot
Top achievements
Rank 1
Share this question
or