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

[Solved] Grid Edit/Delete

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mansi
Top achievements
Rank 1
Mansi asked on 29 Dec 2009, 10:56 AM
In my grid, there are two different columns for edit and delete a record.
And I am opening a popup while editing or inserting a new record.
Now, I need to display the edit and delete buttons at the top like the "Add new" button.

I came across this sample, http://demos.telerik.com/aspnet-ajax/toolbar/examples/applicationscenarios/gridcommanditem/defaultcs.aspx, in which, radtoolbar has been used. But here it is not clear how can I open a popup on edit.
Right now i have one image button and on _ItemDataBound, adding an "onclick" attribute to open popup.
I need to get DataKeyNames for selected row while opening popup.

Is there any direct way to open popup, by, edit button on top ?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Dec 2009, 11:40 AM
Hi Mansi,

You can get the selecteditem from client side and get the corresponding DataKeyValue in order to pass to the window as url parameter when opening the window. Here is the code that I tried.

aspx:
 
 <CommandItemTemplate> 
        <asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="showPopupForm(); return false;" /> 
    </CommandItemTemplate> 

javascript:
 
    function showPopupForm() { 
        var grid = $find("<%= RadGrid1.ClientID %>"); 
        var masterTableView = grid.get_masterTableView(); 
        var row = masterTableView.get_selectedItems()[0]; 
        var dataKeyValue = masterTableView.get_selectedItems()[0].getDataKeyValue("CustomerID"); 
        window.radopen("EditFormCS.aspx?CustomerID=" + dataKeyValue, "UserListDialog"); 
    } 

Hope this helps,
Shinu.
0
Marcus
Top achievements
Rank 1
answered on 04 Mar 2010, 09:37 AM
 function showPopupForm() {  
        var grid = $find("<%= RadGrid1.ClientID %>");  
        var masterTableView = grid.get_masterTableView();  
        var row = masterTableView.get_selectedItems()[0];  
        var dataKeyValue = masterTableView.get_selectedItems()[0].getDataKeyValue("ean");  
        window.radopen("EditFormCS.aspx?Ean=" + dataKeyValue, "UserListDialog");  
    }  

I hope someone can help with the above. The script runs in my app with no errors - but the dataKeyValue returns NULL

The below code works on the Server Side:-

For Each item As GridDataItem In RadGrid_detail.SelectedItems 
             
            Response.Write(item("ean").Text.ToString()) 
             
            Dim ID As String = item.GetDataKeyValue("ean") 
 
        Next 

I am trying to use the Client rather than the Server to return the multiple selected values as I wish to save on round trips to the server.

Do I need some sort of ClientEvents to activate the above Java??

Any help would be Fantastic!!!

PS I am working with a Hierarchical Grid.


Tags
Grid
Asked by
Mansi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marcus
Top achievements
Rank 1
Share this question
or