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

Radgrid column ordering

4 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 28 Sep 2008, 08:25 AM
Within a radgrid, I added one template column in the MasterTableView, while the rest of the radgrid columns were auto-generated via a database query.    However, this template column always displayed as the left-most column, while I expected it to be displayed to the right-most of the grid.    I've tried to change its column index in the prerender event.  It didn't work.  It seemed in the prerender event, the template column was the only column recognized. 
Is there a way to move this "pre-defined" column to the right-most in an auto-generated radgrid?   Thanks!

Shawn

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2008, 04:47 AM
Hello Shawn,

You can swap the columns using their UniqueName properties in the PreRender event of the grid as shown below:
cs:
 
  protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        RadGrid1.MasterTableView.SwapColumns("AutoGeneratedColumn", "PreDefinedColumn");  
    }  
 
You can also go through this link which explains about reordering columns.

Thanks
Princy.
0
Shawn
Top achievements
Rank 1
answered on 29 Sep 2008, 12:46 PM
No it does not work.  As was mentioned in my original post, within the PreRender event only one column (the predefined column) is accessible.   Plus, I'm looking an easy way to move the predefined column to the right-most rather than swapping 20+ dynamically generated columns during runtime.  Thanks.

Shawn


0
Shawn
Top achievements
Rank 1
answered on 29 Sep 2008, 01:32 PM
Just to clerify... Your way of swapping columns works well if I know the column names ahead of time.   However, I had difficulty to access  the column uniquenames in dynamically-generation columns in the prerender event, such as RadGrid1.Columns[i].uniquename. 
Back to the original request,  I want to place the predefined template column (a linked column that will popup another window), to the right of the autogenerated grid.  The grid columns have to in order (just as what come out from the query).  
Thanks in advance.

Shawn
0
Shawn
Top achievements
Rank 1
answered on 29 Sep 2008, 03:41 PM
Problem was resolved.  I worked around to get the column names ahead of time, and then swap columns 1-by-1 by their names. 
Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Shawn
Top achievements
Rank 1
Share this question
or