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

Double click and get value from selected

3 Answers 409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Shelton Agar
Top achievements
Rank 2
James Shelton Agar asked on 01 Aug 2008, 01:25 AM
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!

3 Answers, 1 is accepted

Sort by
0
Accepted
Kevin Babcock
Top achievements
Rank 1
answered on 01 Aug 2008, 02:20 AM
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:

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
        function RadGrid1_RowDblClick(sender, args) {                    
            var index = args.get_itemIndexHierarchical(); 
            var tableView = args.get_tableView(); 
            var dataItems = tableView.get_dataItems(); 
            var dataItem = dataItems[index]; 
            var keyValue = dataItem.getDataKeyValue('ID'); 
            alert(keyValue); 
        } 
    </script> 
</telerik:RadScriptBlock> 
 
<telerik:RadGrid ID="RadGrid1" runat="server" 
    OnNeedDataSource="RadGrid1_NeedDataSource"
    <MasterTableView ClientDataKeyNames="ID"
    </MasterTableView> 
    <ClientSettings> 
        <ClientEvents OnRowDblClick="RadGrid1_RowDblClick" /> 
    </ClientSettings>                
</telerik:RadGrid> 

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

Sincerely,
Kevin Babcock
0
Shinu
Top achievements
Rank 2
answered on 01 Aug 2008, 07:06 AM
Hi James,

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

Shinu.

0
James Shelton Agar
Top achievements
Rank 2
answered on 04 Aug 2008, 09:54 PM
thanks Kevin Babcock, it was a great help to understand client event model and solved my problem, cheers
Tags
Grid
Asked by
James Shelton Agar
Top achievements
Rank 2
Answers by
Kevin Babcock
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
James Shelton Agar
Top achievements
Rank 2
Share this question
or