admin管理员组

文章数量:1432607

I'd like to be able to double click on any part of a given row and open a new html page (based on specific cell value/content). Basically I have all NY counties, each in one row:

County - City - State

Manhatan - New York - NY 

Brooklyn - New York - NY

Bronx - New York - NY

Westchester - New York - NY

etc.

I need to be able to get the cell value in the County column and use it to run a function. Example: if I double click on the first row, that should open a new html page about Manhattan. I tried some answers that were posted for a kind of similar question (about editing) but they didn't work.

I'd like to be able to double click on any part of a given row and open a new html page (based on specific cell value/content). Basically I have all NY counties, each in one row:

County - City - State

Manhatan - New York - NY 

Brooklyn - New York - NY

Bronx - New York - NY

Westchester - New York - NY

etc.

I need to be able to get the cell value in the County column and use it to run a function. Example: if I double click on the first row, that should open a new html page about Manhattan. I tried some answers that were posted for a kind of similar question (about editing) but they didn't work.

Share Improve this question edited May 22, 2013 at 13:17 enb081 4,06112 gold badges45 silver badges66 bronze badges asked Feb 21, 2012 at 18:07 M BenmosM Benmos 993 silver badges13 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4
$('table').on('dblclick', 'tr', function() {
    var rowCountry = $(this).find('td:first').text();
});

This says when you double click on any row in your table, find the first cell of that row, and store its text value in a variable.​

Ondoubleclick of a row in grid call a function.

Use the below lone of code to get the selected row id (primary key of row) and then get the row contents using that id and then get the column content using the column name. Once you have the country name, open whatever page you want based on country.

selId = jQuery("#myGrid").jqGrid('getGridParam','selarrrow');
alert("Selected Id is ->"+selId);
var data = jQuery("#myGrid").jqGrid('getRowData',selId);
alert("Status ->"+data.country);

本文标签: javascriptjqGrid HOWTO Get the value of specific cell upon double click on rowStack Overflow