我需要将我在 JSON 中创建的数组嵌套在另一个数组中,以便为jQuery Datatables 库提供正确的格式。
这是我当前的代码:
$.ajax({
url: uMtbls,
dataType: 'json',
success: function(jMtbl) {
$.each(jMtbl, function(i, item) {
mAll = jMtbl[i];
mOwn = jMtbl[i].OrigOwner;
mPub = jMtbl[i].PublicationTblNm;
mTbl = jMtbl[i].TableId;
mMig = jMtbl[i].MigrationFreq;
mGTYPE = jMtbl[i].GTYPE;
exec();
});
oTable = $('#dtManaged').dataTable({
"bStateSave": true,
"bProcessing": true,
"bServerSide": true,
"aaData": jReform,
"aoColumns": [{
"sName": mOwn,
"sTitle": "Original Owner",
"sWidth": "10%"
}, {
"sName": mPub,
"sTitle": "Table Name"
}, {
"sName": mTbl,
"sTitle": "ID"
}, {
"sName": mMig,
"sTitle": "Migration Frequency"
}, {
"sName": mGTYPE,
"sTitle": "Oracle Gtype"
}],
"sPaginationType": "full_numbers",
"iDisplayLength": 25,
"aLengthMenu": [
[25, 50, 100, -1],
[25, 50, 100, "All"]
]
});
}
});
function exec() {
jBld = mOwn + "," + mPub + "," + mTbl + "," + mMig + "," + mGTYPE;
//console.debug("[" + mOwn + "," + mTbl + "]");
jReform = jBld.split(",");
console.debug(jReform);
}
输出如下所示(在 console.debug 中捕获):
["text","text","text","text","text"]
["text","text","text","text","text"]
样本应该是:
{ "aaData": [
[ 10126, 10002253, 415 ]
]}