如何获取所选行的 id,我使用 jtable
.我播种事件选择更改了,但我不知道如何获取所选行的第一个单元格,即 id。表的名称为 tModelIndex
selectionChanged: function () {
var $selectedRows = $('#tModelIndex').jtable('selectedRows');
if ($selectedRows.length > 0) {
// alert(1);
}
}
查看此链接 这里 你可以找到简单的例子
确保您已在jTable
中使用此功能
selecting: true, //Enable selecting
multiselect: true, //Allow multiple selecting
selectingCheckboxes: true //Show checkboxes on first column
然后在选择更改事件
selectionChanged: function () {
//Get all selected rows
var $selectedRows = $('#tModelIndex').jtable('selectedRows');
if ($selectedRows.length > 0) {
//Show selected rows
$selectedRows.each(function () {
var record = $(this).data('record');
alert(record.StudentId);
alert(record.Name);
});
} else {
//No rows selected logic here
}
}
在此record.StudentId
中,StudentId 表示您在 jTable 中的列名