Customizing AutoGenerated EditColumn and DeleteColumn

6 posts, 0 answers
  1. Softec
    Softec avatar
    45 posts
    Member since:
    Sep 2007

    Posted 19 Jan 2009 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jan 2009 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Softec
    Softec avatar
    45 posts
    Member since:
    Sep 2007

    Posted 20 Jan 2009 Link to this post

    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?
  5. Scott Eoff
    Scott Eoff avatar
    14 posts
    Member since:
    Jun 2005

    Posted 23 Apr 2009 Link to this post

    I'm getting the same problem. Did you ever find a solution?
  6. Kyle
    Kyle avatar
    27 posts
    Member since:
    Sep 2008

    Posted 29 Apr 2009 Link to this post

    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
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Apr 2009 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017