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

Change Radgrid width dynamically to max width

1 Answer 45 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Kishor
Top achievements
Rank 2
Kishor asked on 11 Aug 2014, 07:23 AM
I want to keep max width of Radgrid to 1200px

I am adding cloumns dynamically ,

my requirement is to increase width dynamically as cloumns are added and scrolls when it reach to 1200px


thanks
kishor

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 11 Aug 2014, 09:34 AM
Hi Sawan,

A suggestion is that initially set the width of RadGrid to 0 and set a default HeaderStyle. Then on adding each column increment the width of the RadGrid with the column width till the max limit. You can try as shown below in the sample code snippet:

C#:
//Creating RadGrid with following properties
rgrdSample.Width = Unit.Pixel(0);
rgrdSample.HeaderStyle.Width = Unit.Pixel(200);
rgrdSample.MasterTableView.TableLayout = GridTableLayout.Fixed;
rgrdSample.ClientSettings.Scrolling.UseStaticHeaders = true;
rgrdSample.ClientSettings.Scrolling.AllowScroll = true;
 
//On column creation
 static int width = 0;
 
width = width + Convert.ToInt16(rgrdSample.HeaderStyle.Width.Value);     
if (width <= 1200)
{
    rgrdSample.Width = Unit.Pixel(width);
}      
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();      
boundColumn.DataField = "abcd";
boundColumn.HeaderText ="abcd";
rgrdSample.MasterTableView.Columns.Add(boundColumn);
rgrdSample.Rebind();

Thanks,
Princy
Tags
Upload (Obsolete)
Asked by
Kishor
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Share this question
or