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

RadGrid columns' width

4 Answers 348 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kamel
Top achievements
Rank 1
Kamel asked on 15 Aug 2011, 09:40 AM
Dear Support,
We are trying telerik RadControls for ASP.NET AJAX,
we have a scenario upon which the rad grid columns are not fixed, i.e. they are loaded at runtime, so we set the following in .aspx page.

 
<telerik:RadGrid  ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None">
       <MasterTableView Dir="RTL" >
       </MasterTableView>
       <ClientSettings>
       <Scrolling AllowScroll="true" UseStaticHeaders="true" />
       </ClientSettings>
       </telerik:RadGrid>

and in the .net code, we wrote the following in the Page_Load:
If Not Page.IsPostBack Then
            Dim dt As DataTable
            dt = OpenDT("SELECT * FROM my_table ")
 
            Dim column1 As New GridBoundColumn
            Dim j As Integer
            For j = 0 To 10 'dt.Columns.Count - 1
                column1 = New GridBoundColumn
                RadGrid1.MasterTableView.Columns.Add(column1)
                column1.DataField = "DataEntryDate"
                column1.HeaderText = "Column " & j
                column1.ItemStyle.Width = "1000"
            Next j
 
            RadGrid1.DataSource = dt
            RadGrid1.DataBind()
End If

the problem is that the columns' width is not applied, cell wrapping is occurring (as in the attached file). However, if we add only 5 columns to the grid the columns' width is correct as in attached screen shot 2.
Any suggestions are appreciated.

thank you.

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 15 Aug 2011, 01:48 PM
Hello Kamel,

Note that it is not recommended to use ItemStyle-Width to set column widths. Only HeaderStyle-Width should be used.

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.

0
Baji
Top achievements
Rank 1
answered on 17 Mar 2012, 04:36 PM

In my grid it contains grouping concept according to the field name. Foreach column i set the HeaderStyle.Width in C#. But it is not Coming while rendering the page.

My Grid Code in aspx Page.

My aim is
 page contains one save button and a radgrid with resize option and GroupBy Feature

If user resize the columns and click on save that width we have to save in db now i get that one with HeaderStyle.Width

While rendering grid we have to retrieve the value from DB and Render the grid with the Width from DB.

If no width is there then 50px for each column
0
Pavlina
Telerik team
answered on 20 Mar 2012, 10:41 PM
Hi Baji,

The online example below demonstrates how you can save and restore RadGrid column width after resizing:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx

Give it a try an let me know if it works as you expected.

All the best,
Pavlina
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.
0
Baji
Top achievements
Rank 1
answered on 21 Mar 2012, 11:06 AM
Thank you for reply...............
Tags
Grid
Asked by
Kamel
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Baji
Top achievements
Rank 1
Share this question
or