GridExpandColumn or GridEditCommandColumn

5 posts, 0 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 14 Sep 2009 Link to this post

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

    Posted 15 Sep 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 15 Sep 2009 Link to this post

    Thanks a lot :-) It works!
  5. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 17 Sep 2009 Link to this post

    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
  6. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 23 Sep 2009 Link to this post

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