3
我被下面的代碼卡住了。我想要在數據表中獲取選定行/列的列值。我有使用此代碼獲取jQuery數據表中選定的行/行的列值
代碼的數據表:
var table = $('#tableId').DataTable({
"ajax": {
"url": "Content",
"dataSrc": "",
data: {sectionUrl: "", siteUrl: siteurl}
},
"columns": [
// {"defaultContent": "<input type='checkbox' name='vehicle' id='checkID'>"},
{"data": "postIMAGE", "render": function (data) {
return '<img src=' + data + ' width="154" height="115"/>';
}},
{"data": "postTITLE"},
{"data": "postURL", "render": function (data) {
return '<a href=' + data + ' target="_blank"/>' + data + '</a>';
}},
{"data": "postSection"}
]
});
。
$('#tableId tbody').on('click', 'tr', function() {
$(this).toggleClass('selected');
});
$('#button').click(function() {
var selectedRows = table.rows('.selected').data();
var results = "";
for (i = 0; i < selectedRows.length; i++) {
alert();
}
});
我想獲得列
你嘗試過警報(selectedRows [1])? – sunil
是的,它返回一個對象。 Doent知道如何閱讀該對象。我試着用(selectedRows [i] .length)它顯示undefined在提醒 –
你能發佈你得到的對象嗎 – sunil