-2
我想創建一個JQuery生成的數據源的數據表。JQuery的數據表對象數據源不工作
我有這樣的對象:
[
{
"a": -817,
"b": null,
"c": "Default",
"total": -817
},
{
"a": -21,
"b": 12,
"c": "Default",
"total": -897
}
]
而這個數據表:
table1.DataTable({
"ajax": dataSource,
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{
"orderable": true,
"data": "a",
"defaultContent": ''
},
{
"orderable": true,
"data": "b",
"defaultContent": ''
},
{
"orderable": true,
"data": "c",
"defaultContent": ''
},
{
"orderable": true,
"data": "total",
"defaultContent": ''
}
],
"paging": false,
"bInfo": false,
"bFilter": false,
"order": [
[1, "asc"]
]
)};
我試圖操縱數據源是這樣的:
- JSON.stringify(數據源)
- 加數組之前的字段({data:datasource})並更改ajax 「ajax」:{「url」:datasource,「dataSrc」:「data」}有或沒有stringihfy
沒有什麼似乎工作。
請幫助
的問候,伊
謝謝,但它幾乎解決了問題。 我改變你的小提琴模擬我的問題: https://plnkr.co/edit/EmjE11nnx8amkBTiBK2t?p=preview 我必須生成內聯數據(它是一個對象的一部分)。 –
試試這個: https://plnkr.co/edit/YZxiSjslpSOApypi2GUQ?p=preview –
是的......我試圖避免操縱對象並創建這個值的數組。如果沒有其他選擇,我會這樣做。謝謝。 –