1 回答
TA贡献1877条经验 获得超1个赞
解决!
将我的Java脚本更改为以下内容,它的工作原理是:
<script>
$(document).ready(function() {
// ============== ==============
var jsTable = $('#example').DataTable({ // added: var jsTable =
// $('#example').dataTable({
'scrollX': true,
'pagingType': 'numbers',
'processing': true,
'serverSide': true,
'ajax': 'datatablesServerSide.php',
"columnDefs": [{"render": createManageButtonFunc, "data": null, "targets": [0]}],
});
// ============== Next 7 lines were added ==============
$('#example').on('click', 'tr', function(){
// var jsData = jsTable.fnGetData(this); <== fnGetData deprecated!!!
jsTable = $('#example').DataTable();
var jsData = jsTable.row(this).data();
$('#accUserId').text(jsData[1]);
$('#accUserName').val(jsData[2]);
})
// =====================================================
});
function createManageButtonFunc() {
return '<button id="manageBtn" type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#manageModal">Manage</button>';
}
</script>
- 1 回答
- 0 关注
- 53 浏览
添加回答
举报