javascript - jqGrid HOWTO: Get the value of specific cell upon double click on row - Stack Overflow

I'd like to be able to double click on any part of a given row and open a new html page (based on

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745604117a4635574.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信