gpt4 book ai didi

javascript - 数据表未将 Json 与列绑定(bind)

转载 作者:行者123 更新时间:2023-12-03 12:01:08 24 4
gpt4 key购买 nike

这是我的代码

oTable = $('#userlisttable')
.dataTable(
{
"serverSide" : false,
"ajax" : {
"url" : context + "user/get",
},
"columns" : [ {
"data" : "username"
}, {
"data" : "userpassword"
}, {
"data" : "usertype"
}, {
"data" : "firstname"
}, {
"data" : "lastname"
}, {
"data" : "emailaddress"
}, {
"data" : "isactive"
}, ],


"columnDefs" : [ {
"targets" : "7",
"data" : "userId",
"render" : function(data, type,
full, meta) {
return '<a href="#" id="row'
+ data
+ '" class="btn btn-success" onclick="callModal(id)"><i class="glyphicon glyphicon-edit icon-white"></i>EDIT</a> &nbsp;&nbsp;<a href="#" id="row'
+ data
+ '" class="btn btn-danger" onclick="callDeleteModal(id)"><i class="glyphicon glyphicon-trash icon-white"></i>Deactivate</a>';
}
} ],

"sDom" : 'T<"clear">lfrtip',
"oTableTools" : {
"sRowSelect" : "single",
"sSwfPath" : "../../resources/swf/copy_csv_xls_pdf.swf",
"aButtons": [
"csv"
]
}

});

服务器返回以下 Json

[{"password":"password","username":"user","lastAccess":1408089626000,"creationDate":1408089626000,"userId":1,"lastName":"reddy","isActive":"y","firstName":"manjari","email":"man@gmail.com","isLdap":"y","ldapQuery":"query","accessType":"any","usertype":"admin"}]

但数据未显示在数据表中。

最佳答案

来自doc on the ajax option (向下滚动到示例):

Get JSON data from a file via Ajax, using dataSrc to read data from a plain array rather than an array in an object:

$('#example').dataTable( {
"ajax": {
"url": "data.json",
"dataSrc": ""
}
} );

关于javascript - 数据表未将 Json 与列绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25409368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com