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

GridEditCommandColumn

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 19 Mar 2009, 11:37 AM

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 ?

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Mar 2009, 10:42 AM
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
0
mww
Top achievements
Rank 1
answered on 20 Mar 2009, 12:34 PM
the example you provided uses a hyperlink for editing, not a button, so Im still none the wiser
0
Princy
Top achievements
Rank 2
answered on 20 Mar 2009, 01:50 PM
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.
Tags
Grid
Asked by
mww
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
mww
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or