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

Border width

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 03 May 2013, 08:28 PM
Hi I'm trying to set grid width to auto but div border is always 100%
i tried this:

.rgMasterTable

{
    width: auto !important;
}

 

but I get what is on the image

if I try to overwrite the style in the master table view it renders the width attribute twice, like this:
<table cellspacing="0" class="rgMasterTable" id="RadGrid1_ctl00" style="width:100%;width:auto;table-layout:auto;empty-cells:show;">

I want that the colums width adjusts to the content, It works if I put the grid inside a table td but there must be a better way
also works inside a div with display:inline-table but not in IE7
I'm using Q1 2010

please advise
thanks!

code:

<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"
            onneeddatasource="RadGrid1_NeedDataSource">
            <MasterTableView style="width:auto;">
            </MasterTableView>
        </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 02 Aug 2013, 12:22 PM
Hi Carlos,

I guess you want the contents of the column to fit inside the grid column.Please try using the resizeToFit method to resize the column to fit the widest cell's content without wrapping.

ASPX:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function pageLoad() {
            var grid = $find("<%= RadGrid1.ClientID %>");
            var columns = grid.get_masterTableView().get_columns();
            for (var i = 0; i < columns.length; i++) {
                columns[i].resizeToFit();
            }
        }
    </script>
</telerik:RadCodeBlock>
 . . . . . . . . . . . . . . . . . . . . . . .
<telerik:RadGrid id="RadGrid1" runat="server">
    <ClientSettings>
        <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" AllowResizeToFit="true" />
    </ClientSettings>
</telerik:RadGrid>

Thanks,
Princy
Tags
Grid
Asked by
Carlos
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or