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

How to set column width to fit, when UseStaticHeaders="false"

1 Answer 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zhenyu
Top achievements
Rank 1
Zhenyu asked on 03 Jul 2012, 11:51 PM
Hi,

Title has a typo...
How to set column width to fit, when UseStaticHeaders="true"

I have a RadGrid which likes this:

            <telerik:RadGrid ID="CRMGrid" runat="server" AllowSorting="true" GridLines="None" OnSortCommand="CRMGrid_SortCommand" OnItemDataBound="CRMGrid_ItemDataBound" AllowMultiRowSelection="true" OnSelectedIndexChanged="CRMGrid_SelectedIndexChanged" ShowHeader="true">
                <HeaderStyle Width="100px" />
                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Selecting AllowRowSelect="true" />
                    <Scrolling AllowScroll="True" UseStaticHeaders="true" FrozenColumnsCount="1"/>
                </ClientSettings>
                <SelectedItemStyle CssClass="SelectedItem" />
                <MasterTableView Font-Names="Arial,sans-serif" TableLayout="Auto">
                    <Columns>
                        <telerik:GridClientSelectColumn>
                            <HeaderStyle Width="35" />
                            <ItemStyle Width="35" />
                        </telerik:GridClientSelectColumn>
                    </Columns>
                    <CommandItemSettings ShowExportToCsvButton="true" />
                    <HeaderStyle Font-Bold="true"/>
                </MasterTableView> 
            </telerik:RadGrid>

If UseStaticHeaders="true", then header and content are in 2 <div> and 2 <table> tags, table layout is fixed and column width can NOT be fit to max length of cell content. See picture 1.
If UseStaticHeaders="false", then header and content are in same div and table, column width is auto-fit, but header disappears when scroll down.See picture 2.

Any suggestion?
Thanks a lot.

Zhenyu Wang 


1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 06 Jul 2012, 02:44 PM
Hello Zhenyu,

When you enable static headers and provide width for even a single column, the fixed table-layout is triggered for the grid (it is also triggered by some other client features of the control).
One option that you could try if you do not have other features like column resizing enabled, is to remove the Width setting for the GridClientSelectColumn.
In case this does not help, you would need to explicitly set column widths in pixels (through HeaderStyle-Width) property in order to get them to the desired dimensions.

Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Zhenyu
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or