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

Customizing AutoGenerated EditColumn and DeleteColumn

5 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Softec
Top achievements
Rank 1
Softec asked on 19 Jan 2009, 08:07 AM
Hi

How can I change the ButtonType and the column position of the delete and edit column generated by AutoGenerateEditColumn/AutoGenereateDeleteColumn? 

And where should i create the rest of the columns on codebehind? I want to implement a custom autogenerate columns method, where I check a config file for creating columns. Where should i implement this logic? I want to have access to the bound datasource, to check the date type of the bound properties vs my columns.

Thanks beforehand

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jan 2009, 10:37 AM
Hi,

Try the following code snippet in the ColumnCreated event to set the ButtonType of the AutoGenerated edit and delete column.

CS:
   protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column.UniqueName == "AutoGeneratedEditColumn"
        { 
            GridEditCommandColumn editcol = (GridEditCommandColumn)e.Column; 
            editcol.ButtonType = GridButtonColumnType.PushButton; 
        } 
        if (e.Column.UniqueName == "AutoGeneratedDeleteColumn"
        { 
            GridButtonColumn btncol = (GridButtonColumn)e.Column; 
            btncol.ButtonType = GridButtonColumnType.PushButton; 
        } 
    } 

Reorder the columns in the server side using the SwapColumns method:
protected void RadGrid1_PreRender(object sender, EventArgs e)   
{   
    RadGrid1.MasterTableView.SwapColumns(2, 9);   
}  
 

You can dynamically create the columns and add it to the Grid's column collection in the PageLoad event.

Thanks
Shinu.

0
Softec
Top achievements
Rank 1
answered on 20 Jan 2009, 05:31 PM
Hi

I'm now using the OrderIndex Property of the GridColumn Object to reorder my Columns depending on a Config File. This only works if i'm calling SwapColumns afterwards, like this.MasterTableView.SwapColumns(0, 0);
But if im entering InPlace Edit i get NullReferenceException calling the SwapColumns() method. 

Do you have any suggestion where the problem lies? 
Is this a known bug, especially the part of OrderIndex not working without calling SwapColumns?
0
Scott Eoff
Top achievements
Rank 2
answered on 23 Apr 2009, 05:26 PM
I'm getting the same problem. Did you ever find a solution?
0
Kyle
Top achievements
Rank 1
answered on 29 Apr 2009, 09:51 PM
I would like my auto generated edit column to be to the right of my auto generated grid columns.  This sounds like the same issue as this thread.  Is this possible to accomplish?  I was not able to get it to work by setting order indexes in the column created event.  Those seem to be ignored.

Thanks,
Kyle LeMarbe
0
Princy
Top achievements
Rank 2
answered on 30 Apr 2009, 03:57 AM
Hello Kyle,

You can reorder the columns using their unique names as shown below:
c#:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.SwapColumns("AutoGeneratedEditColumn","LastColumnUniqueName"); 
    // UniqueName for an AutoGenerated column is the same as the DataField
    } 

Thanks
Princy.
Tags
Grid
Asked by
Softec
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Softec
Top achievements
Rank 1
Scott Eoff
Top achievements
Rank 2
Kyle
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or