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

Enable to find DataKeyValues on click in Context menu in Grid row

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaswant Singh
Top achievements
Rank 1
Jaswant Singh asked on 26 Mar 2010, 06:22 PM

Hi

I have a RadGrid, I have now been tasked with putting a Right Click Context menu in place. What I need to figure out is:


1)     How can I get a value from the either the DataItem or the DataKeyValues from client side for the row that has fired off the
        context menu?   

    
Any thoughts / pointers most appreciated

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Mar 2010, 02:11 PM

Hello,

Here is the client code which shows how to access the DataKeyValue on right-clicking the row.

JavaScript:

   
    function RowContextMenu(sender, eventArgs) {    
        var menu = $find("<%=RadMenu1.ClientID %>");    
        var evt = eventArgs.get_domEvent();    
        var grid = $find("<%=RadGrid1.ClientID %>");    
        if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") {    
            return;    
        }    
   
        var index = eventArgs.get_itemIndexHierarchical();  //  index    
        var dataItem = sender.get_masterTableView().get_dataItems()[index]; //  dataitem    
        alert(dataItem.getDataKeyValue("Name"));    
           . . .     
    }  

-Shinu.

Tags
Grid
Asked by
Jaswant Singh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or