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

GridExpandColumn or GridEditCommandColumn

4 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roy Halvorsen
Top achievements
Rank 1
Roy Halvorsen asked on 14 Sep 2009, 01:31 PM
How can I make a GridEditCommandColumn work as a GridExpandColumn?
<telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="../Grafikk/RadGrid/SinglePlus.gif" EditText="Edit" CancelImageUrl="../Grafikk/RadGrid/SingleMinus.gif" CancelText="Cancel" ItemStyle-HorizontalAlign="Center" /> 

First I want the PLUS gif to become a MINUS gif when clicked and my EditFormTemplate opens, and when I click on MINUS, a cancel command is fired.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Sep 2009, 05:25 AM
Hi Roy,

I would suggest you to use a GridTemplateColumn instead of using a GridEditCommandColumn to achieve the desired scenario. Here is a sample code which worked on my end.

ASPX:
 
<telerik:GridTemplateColumn UniqueName="EditTemp" HeaderText="EditCol" > 
                     <ItemTemplate> 
                         <asp:ImageButton ID="imgBtnEdit" runat="server" ImageUrl="~/Image/SinglePlus.gif" CommandName="EditItem"  /> 
                     </ItemTemplate> 
                   </telerik:GridTemplateColumn> 

CS:
 
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        //to set the Grid in edit mode 
        if (e.CommandName == "EditItem"
        { 
            e.Item.Edit = !e.Item.Edit; 
        } 
        RadGrid1.MasterTableView.Rebind(); 
    } 
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        {  
            //to toggle the ImageURL 
           ImageButton editBtn = (ImageButton)item.FindControl("imgBtnEdit"); 
           if (item.Edit) 
               editBtn.ImageUrl = "~/Image/SingleMinus.gif"
           else 
               editBtn.ImageUrl = "~/Image/SinglePlus.gif"
               
        } 
    } 


Regards
Shinu
0
Roy Halvorsen
Top achievements
Rank 1
answered on 15 Sep 2009, 06:56 AM
Thanks a lot :-) It works!
0
Roy Halvorsen
Top achievements
Rank 1
answered on 17 Sep 2009, 01:37 PM
Seems like I was a bit quick to shout hooray, Shinu. Now the radgrid is not updated until i open one of the newly edited items. Also functionality that I run in RadGrid_UpdateCommand is not firing, such as showing an invisible panel if some conditions are true.

Roy
0
Yavor
Telerik team
answered on 23 Sep 2009, 08:05 AM
Hi Roy,

The question set forth was addressed in the support ticket that you opened on the matter.
To avoid duplicate posts, we can continue our communication there.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Roy Halvorsen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Roy Halvorsen
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or