GridEditCommandColumn

4 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 19 Mar 2009 Link to this post

    Im using a RADWindow to edit data in a grid, insert works fine using this in the grid

     

    <

     

    CommandItemTemplate>

     

     

    <a href="#" onclick="return ShowInsertForm();"> <img style="border:0px;" alt="Add New Record" src="RadControls/Grid/Skins/Vista/AddRecord.gif" />

     

    Add New Homepage Item

    </a>

     

     

     

     

    </CommandItemTemplate>

     

     


    I have this code in the grid to access the edit mode using a button and a javascript function to open the RADWindow, but cant see a way to call the javascript function to show the RADWindow for editing from the actual button itself

    <

     

    telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1">

     

     

    <HeaderStyle Width="20px" />

     

     

     

    </telerik:GridEditCommandColumn>

    how can I do this ?

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Mar 2009 Link to this post

    Hi,

    You may access the edit button in the code behind and call the function to show the RadWindow. Refer the following online demo which implements a similar scenario.
    Window Editing

    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 20 Mar 2009 Link to this post

    the example you provided uses a hyperlink for editing, not a button, so Im still none the wiser
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Mar 2009 Link to this post

    Hello,

    You can try out the following code to open a RadWindow on clicking a Button in a row in the grid :
    aspx:
     <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" >  
              <MasterTableView DataSourceID="SqlDataSource1"  Name="Master">  
                <Columns>   
                 <telerik:GridTemplateColumn UniqueName="Edit">        
            <ItemTemplate> 
             <asp:Button ID="Button1" runat="server" Text="Edit" />           
                
            </ItemTemplate> 
            </telerik:GridTemplateColumn>      
                .... 
                </Columns>  
                  .... 

    cs:
     
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem
            {  
                GridDataItem dataItem = (GridDataItem)e.Item;  
                Button btn = (Button)dataItem["Edit"].FindControl("Button1");  
                btn.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');",e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"], e.Item.ItemIndex);  
            }  
        }  

    js:
    function ShowDetails(id, rowIndex) 
                { 
                    var grid = $find("<%= RadGrid1.ClientID %>"); 
                     
                    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); 
                    grid.get_masterTableView().selectItem(rowControl, true); 
                             
                    window.radopen("EditForm.aspx?EmployeeID=" + id, "UserListDialog"); 
                    return false; 
                 

    Thanks
    Princy.
Back to Top