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

[Solved] Edit Column Width Increase

2 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bharat kumar
Top achievements
Rank 1
bharat kumar asked on 09 Mar 2010, 10:27 AM

Hi

i have a rad frid craeted dynamicaly and i want to increase the width of the column in Edit mode.
i tried several things but failed.

boundNameColumn.FilterControlWidth =

Unit.Pixel(600);

 

 

boundNameColumn.HeaderStyle.Width = Unit.Pixel(600);

 

boundNameColumn.ItemStyle.Width =

Unit.Pixel(600);

 

grid.ClientSettings.EnableAlternatingItems =

true;

 

grid.MasterTableView.AlternatingItemStyle.BackColor =

Color.FromName("#F2F3F5");

 

grid.MasterTableView.TableLayout =

GridTableLayout.Fixed;

 

grid.MasterTableView.AllowFilteringByColumn =

true;

 


grid.MasterTableView.EditMode =

GridEditMode.InPlace;

 

grid.MasterTableView.EditItemStyle.Width =

Unit.Pixel(600);

 



please suggest how to achieve this.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2010, 12:33 PM
Hi,

In order to increase the width of the column, you need to increase the Header Style width. Give this a try and let me know how it goes.

C#
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        if (RadGrid1.EditIndexes.Count  > 0) 
        { 
            GridBoundColumn col = (GridBoundColumn)RadGrid3.MasterTableView.GetColumnSafe("Item"); 
            col.HeaderStyle.Width = Unit.Pixel(600); 
        } 
        else 
        { 
            GridBoundColumn col = (GridBoundColumn)RadGrid3.MasterTableView.GetColumnSafe("Item"); 
            col.HeaderStyle.Width = Unit.Pixel(300); 
        } 
    } 


Thanks,
Princy
0
bharat kumar
Top achievements
Rank 1
answered on 09 Mar 2010, 01:29 PM

Hi,
 Thanks for the reply.
as i have the dynamic grid created at code behind so the above code doesn't work.

i have written that in below way but it not work.

protected

 

void grid_PreRender(object sender, EventArgs e)

 

{

 

RadGrid grid = grdPlaceHolder.FindControl("grid") as RadGrid;

 

 

if (grid != null)

 

{

 

if (grid.EditIndexes.Count > 0)

 

{

 

GridBoundColumn col = (GridBoundColumn)grid.MasterTableView.GetColumnSafe("Item");

 

col.HeaderStyle.Width =

Unit.Pixel(600);

 

}

 

else

 

{

 

GridBoundColumn col = (GridBoundColumn)grid.MasterTableView.GetColumnSafe("Item");

 

col.HeaderStyle.Width =

Unit.Pixel(300);

 

}

}

}

and on page_init it is like...

..
..
..

grid.PreRender +=

new EventHandler(grid_PreRender);

 

grid.AllowSorting =

true;

 

grdPlaceHolder.Controls.Add(grid);
..

..

please suggest.

thanks in advance.
Tags
Grid
Asked by
bharat kumar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
bharat kumar
Top achievements
Rank 1
Share this question
or