Gurunadh
Gurunadh

Reputation: 463

how to get datakey value when row double click radgrid

i am using the following code to get datakey value when row double click, now i want to use this key value in serverside, how can i get this value there(or) how to pass this value to server side?

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> 
    <script type="text/javascript"> 
        function RadGrid1_RowDblClick(sender, args) {                    
            var keyValue = dataItem.getDataKeyValue('WageID'); 
            // want to get this keyvalue in server side 
        } 
    </script> 
</telerik:RadScriptBlock> 

<telerik:RadGrid ID="RadGrid1" runat="server" 
    OnNeedDataSource="RadGrid1_NeedDataSource"> 
    <MasterTableView ClientDataKeyNames="ID"> 
    </MasterTableView> 
    <ClientSettings> 
        <ClientEvents OnRowDblClick="RadGrid1_RowDblClick" /> 
    </ClientSettings>                
</telerik:RadGrid> 

Upvotes: 0

Views: 7372

Answers (3)

Gurunadh
Gurunadh

Reputation: 463

Finally i got the answer for this question, following is the answer

   <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> 
<script type="text/javascript"> 
    function RadGrid1_RowDblClick(sender, args) { 
    //changed code here 
      var grid = $find("<%= RadGrid1.ClientID %>");
            var MasterTable = grid.get_masterTableView();
            var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
            var key = MasterTable.getCellByColumnUniqueName(row, "WageID");  // get the value by uniquecolumnname
            var ID = key.innerHTML;        
            MasterTable.fireCommand("MyClick2",ID);        
     } 
</script> 
</telerik:RadScriptBlock> 

<telerik:RadGrid ID="RadGrid1" runat="server" 
OnNeedDataSource="RadGrid1_NeedDataSource"> 
<MasterTableView ClientDataKeyNames="ID"> 
</MasterTableView> 
<ClientSettings> 
    <ClientEvents OnRowDblClick="RadGrid1_RowDblClick" /> 
</ClientSettings>                
</telerik:RadGrid>

//add this code under itemcommand event of radgrid.

if (e.CommandName == "MyClick2")
    {
        object obj = e.CommandArgument;
        string ID = obj.ToString();
        //logic to fulfill our requirment.
    }

Upvotes: 1

Saritha.S.R
Saritha.S.R

Reputation: 800

You can get the datakeyvalue on client side using the following code:

function OnRowDblClick(sender, args) {

         var key=  args.getDataKeyValue("WageID");
   document.getElementById('<%= HidenField1.ClientID %>').value = key;

    } 

To pass these value to server side one suggestion is you can assign this to a hiddenfield and access that hiddenfield in server side.

Upvotes: 0

Related Questions