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

RadGrid Column Width Auto

3 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aman bindaal
Top achievements
Rank 1
aman bindaal asked on 20 Sep 2013, 08:34 PM
Hi I am binding a radgrid and column width is adjusted by a cssclass as shown below in code, But issue is, this css works on column data but not on hearders... i am reffering to latest telerik dll.

<style type="text/css">
    .AutoShrink {
        width: auto !important;
    }
</style>
<telerik:RadGrid ID="rgWorkInProgress" runat="server" AllowPaging="True" AllowSorting="True" ShowStatusBar="True"
    AutoGenerateColumns="False" PageSize="10" ShowGroupPanel="False" AllowFilteringByColumn="true"
    CellSpacing="0" GridLines="None" EnableTheming="true" AllowCustomPaging="true"
    OnNeedDataSource="rgWorkInProgress_NeedDataSource" OnPageIndexChanged="rgWorkInProgress_PageIndexChanged"
    OnSortCommand="rgWorkInProgress_SortCommand" HeaderStyle-CssClass="AutoShrink">

    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />

    <ClientSettings AllowDragToGroup="false">
        <Resizing AllowColumnResize="true" AllowResizeToFit="true" />
        <Scrolling AllowScroll="True" UseStaticHeaders="true" SaveScrollPosition="true" />
        <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
    </ClientSettings>

    <MasterTableView TableLayout="Auto" AllowCustomSorting="true" AllowNaturalSort="false" AllowFilteringByColumn="True" CssClass="AutoShrink">

        <EditFormSettings>
            <EditColumn />
        </EditFormSettings>

        <HeaderStyle HorizontalAlign="Left" Wrap="false" CssClass="AutoShrink"/>
        <FilterItemStyle HorizontalAlign="Left" Wrap="false" />
        <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Wrap="false" />

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 21 Sep 2013, 07:44 AM
Hi ,

I have tried your code and it works fine, Since you have set AllowFilteringByColumn="true", the width is occupying the space to set the filter,when you remove the filtering,you can see the difference.You can set the CSS in the MasterTableView as follows,you can also adjust the width of the columns according to the headers.

ASPX:
<MasterTableView  CssClass="AutoShrink">

CSS:
<style type="text/css">
  .AutoShrink
    {
    width: 240px !important;
    }
</style>

Thanks,
Princy
0
aman bindaal
Top achievements
Rank 1
answered on 23 Sep 2013, 03:45 PM
Hi, Than you very much for your suggestion, Unfortunately that thing doesnt work, 

 I applied same css to headers also, but its not working, In fact headers are taking width much more than filters...

have a look on the attached image...
0
Eyup
Telerik team
answered on 25 Sep 2013, 08:07 AM
Hi Aman,

You can try the following approach:
http://www.telerik.com/help/aspnet-ajax/grid-gridcolumn-resizetofit.html

Hope this helps.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
aman bindaal
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
aman bindaal
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or