Double click and get value from selected

4 posts, 1 answers
  1. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 31 Jul 2008 Link to this post

    Hi, i tried to get ID from row double click, but it always shows a null.
    here's my JS...
     function EditAct(sender, eventArgs) {  
                    var grid = sender;  
                    var MasterTable = grid.get_masterTableView();  
                    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];  
                    alert(row.getDataKeyValue('Act_No'));  
                } 

    which always return null
    here is my Grid Click Event

    <ClientEvents OnRowDblClick="EditAct" />

    any assistance would be appreciated, thanks!

  2. Answer
    Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 31 Jul 2008 Link to this post

    Hello James,

    When configuring your RadGrid, make sure you are adding the names of the columns you want to access to its ClientDataKeyNames collection. Here is an example:

    1 <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    2 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    3     <script type="text/javascript"
    4         function RadGrid1_RowDblClick(sender, args) {                    
    5             var index = args.get_itemIndexHierarchical(); 
    6             var tableView = args.get_tableView(); 
    7             var dataItems = tableView.get_dataItems(); 
    8             var dataItem = dataItems[index]; 
    9             var keyValue = dataItem.getDataKeyValue('ID'); 
    10             alert(keyValue); 
    11         } 
    12     </script> 
    13 </telerik:RadScriptBlock> 
    14  
    15 <telerik:RadGrid ID="RadGrid1" runat="server" 
    16     OnNeedDataSource="RadGrid1_NeedDataSource"
    17     <MasterTableView ClientDataKeyNames="ID"
    18     </MasterTableView> 
    19     <ClientSettings> 
    20         <ClientEvents OnRowDblClick="RadGrid1_RowDblClick" /> 
    21     </ClientSettings>                
    22 </telerik:RadGrid> 

    I hope this helps. If you have further questions, please don't hesitate to ask.

    Sincerely,
    Kevin Babcock
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Aug 2008 Link to this post

    Hi James,

    You can also refer this help article regarding extracting key values on the Client side.

    Shinu.

  5. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 04 Aug 2008 Link to this post

    thanks Kevin Babcock, it was a great help to understand client event model and solved my problem, cheers
Back to Top