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

Problem with Columns width

5 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 21 Jul 2014, 11:49 AM
Hello,

I am working on a project with a RadGrid that has DetailView.
The RadGrid has a lot of columns.
I want the columns’ width to auto-size by content.

I have the following code: 
VB.NET:
RadGrid1.AllowSorting = True
adGrid1.MasterTableView.AllowSorting = True
adGrid1.ClientSettings.Scrolling.UseStaticHeaders = True
adGrid1.MasterTableView.PageSize = 30
adGrid1.MasterTableView.AllowPaging = True
adGrid1.AllowPaging = False

ASPX:
    <style type="text/css">
 
        #RadGrid1Panel, .RadGrid, .RadGrid_Default{
            width: 700px !important;
        }
    </style>
 
<telerik:RadGrid ID="RadGrid1" runat="server" MasterTableView-EnableHeaderContextMenu="true" Height="900px" Width="700px" >
                            <ClientSettings>
                                   <Scrolling AllowScroll="True"></Scrolling>
                                 
                            </ClientSettings>
 </telerik:RadGrid>

When I add the following code, all columns’s width get “squashed”:
Dim tableViewOrders = New GridTableView(RadGrid1)
RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders)

How can I solve this?

I have attached video link that shows this issue:
[video link]


Thanks,
Daniel.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 21 Jul 2014, 12:19 PM
Hi Daniel,

Please set HeaderStyle-Width property for grid columns which is required when static headers are enabled. Also, note that it is not recommended to set ItemStyle-Width.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" MasterTableView-EnableHeaderContextMenu="true" Height="900px" Width="700px"  >
  <HeaderStyle Width="100px" />
    <ClientSettings>
      <Scrolling AllowScroll="True"></Scrolling>
    </ClientSettings>
</telerik:RadGrid>

Thanks,
Princy
0
Daniel
Top achievements
Rank 1
answered on 23 Jul 2014, 07:00 AM
Hi Princy,

Thank you for the solution.

However, this solution is not good for my project because each column gets a fixed size.
My project needs that each column’s size will be according to that column’s content.

I will be glad if you can provide such a solution!

Thanks,
Daniel.
0
Princy
Top achievements
Rank 1
answered on 23 Jul 2014, 08:48 AM
Hi Daniel,

Another way to adjust column width is to fit the widest cell's content without wrapping, you can take a look at this documentation on resizeToFit.

Thanks,
Princy
0
Daniel
Top achievements
Rank 1
answered on 23 Jul 2014, 09:47 AM
Hi Princy,

Thank you for the quick solution.

However, this solution is not good for my project because it works only on the MasterTableView and not on the DetailView.

I will be glad if you can provide a solution that works also on the DetailView!

 
Thanks,
Daniel.
0
Princy
Top achievements
Rank 1
answered on 24 Jul 2014, 12:33 PM
Hi Daniel,

The only way to have the alignment correct is remove the UseStaticHeaders property, or if you want to set this property, you will have to set the HeaderStyle.Width, which is mentioned here.

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