简体   繁体   English

jQuery,使用jtable获取所选行的列数据

[英]Jquery, getting the column data of selected row using jtable

I have 3 fields in my jtable; 我的jtable中有3个字段; Name, Age, Occupation.Lets say I select a specific row, How would i get the specific column data of that row? 名称,年龄,职业。假设我选择了特定的行,我将如何获取该行的特定列数据?

Ex: 例如:

I select the following row: Row 2: Joe Brown, 25, Teacher 我选择以下行:第2行:25岁的乔·布朗,老师

How would I get the age data (which is 25) of that row ? 我将如何获取该行的年龄数据(25岁)?

Thanks 谢谢

PS: I intend to delete that row, so I need the name to query the sql database properly (im using jdbc) PS:我打算删除该行,因此我需要正确查询sql数据库的名称(即使用jdbc)

$('#yourTable tr').each(function() {
    var age = $(this).find("td").eq(1).html();    
    alert(age);// for testing purpose
});

You will get the value of the second row (the index is zero-based) 您将获得第二行的值(索引从零开始)

var rowIndex = // the zero based index of the selected row
var age = $('.jtable tbody').children(rowIndex).children('td').eq(1).text(); // return the age

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM