[英]jTable how getting selected row data
如何从jTable中选择的行中获取数据? 例如,我单击第一行,所选行的数据进入我的输入框。
您可以通过注册事件“ selectionChanged”来获得选定的元素,如下所示,
$('#tableName').jtable({
selecting: true,
columnResizable: false,
actions: {
},
fields: {
KeyId: {
key: true,
create: false,
list: false
},
Name: {
title: 'Name',
sorting: true
},
Description: {
title: 'Description',
create: false,
list: false
},
StartDate: {
title: 'Start Date'
},
EndDate: {
title: 'End Date'
},
Status: {
title: 'Status',
list: false
}
},
//Register to selectionChanged event to handle events
selectionChanged: function () {
var $selectedRows = $('#tableName').jtable('selectedRows');
$selectedRows.each(function () {
var record = $(this).data('record');
var keyid = record.KeyId;
var name = record.Name;
alert(" KeyId:" + keyid + " Name:" + name);
});
}
});
您可以使用以下代码获取json字符串中的所有表记录数据:
/* Read each record and add it to json */
var $selectedRows = $('#your_table').jtable('selectedRows'),records = [];
$selectedRows.each(function () {
var record = $(this).data('record');
records.push(record);
});
var josn_data = JSON.stringify(records);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.