Search code examples
visual-studio-2010telerikradgridview

Obtaining a hidden column value from the selected row in a Telerik RadGridView


How do I obtain the selected row value for a hidden column in a Telerik RadGridView? The column is hidden on the aspx page and I would like to retrieve the value on the client side (JavaScript).

Essentially, I want to display a name in the grid view and be able to retrieve a value from the hidden field "ID" to bring up an edit form.

Here is an example of how I'm hiding the RadGridView column.

code sample:

    onKeyPressEvent(sender, args) { 
  var variable = function (e) { 
    e = e || window.event; 
    if (e.keyCode == 13) { 
      var PartyID = args.getDataKeyValue("PARTY_ID"); 
      var oManager = '<%=winMgr.ClientID %>';
      var oManager = window.radopen("AttorneyEdit.aspx?PARTY_ID=" + PartyID, null); 
      oManager.setSize(1000, 530); 
      //Width, Height oManager.center(); 
      } else { return true; 
      } 
  } 
  theForm.onkeypress = variable 
} 

Thanks for your help...


Solution

  • maybe you're going the wrong way. There is a property called "ClientDataKeyNames" on the mastertableview. You can add several key separated by a comma in this property. Then you'll be able to get your value without adding an extra column.

    You should do something like this:

     function onKeyPressEvent(sender, args) { 
        if (args.get_keyCode() == 13) {
            var dataItem=sender.get_selectedItems()[0];
            var PartyID = dataItem.getDataKeyValue("PARTY_ID"); 
            var oManager = '<%=winMgr.ClientID %>';
            var oManager = window.radopen("AttorneyEdit.aspx?PARTY_ID=" + PartyID, null); 
            oManager.setSize(1000, 530); 
            //Width, Height oManager.center(); 
            } 
            else { 
              return true; 
            } 
     } 
    

    good luck