1 回答

TA貢獻1909條經驗 獲得超7個贊
可以觀察到的是,您不知道密鑰,因為它是動態的。您可以做的是進行 ajax 調用并獲取變量中的數據?,F在您必須平坦響應,以便可以將平坦數組傳遞到 Bootstrap 表。您不使用data-url屬性,而是遵循 fiddle 中給出的過程
我添加了一個小提琴,您可以將其用作示例。我還添加了適當的評論。
超文本標記語言
<link href="https://unpkg.com/[email protected]/dist/bootstrap-table.min.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/bootstrap-table.min.js"></script>
<table id="table">
<thead>
<tr>
<th data-field="betrag">betrag</th>
<th data-field="autorisiert-durch">autorisiert-durch</th>
<th data-field="unix">unix</th>
</tr>
</thead>
</table>
你的腳本應該是
<script>
var $table = $('#table')
$(function() {
// do an ajax call here to get the response. your response should be like responseData
var responseData = {
"1604400036082-3450": {
"betrag": -367.5,
"von/an_uuid": "asdqwe2413",
"von/an": "Test1",
"autorisiert-durch": "SYSTEM",
"unix": 1604400036,
"transaktionsart": "überweisung"
},
"1604406781759-8437": {
"betrag": 85.17,
"von/an": "Test2",
"autorisiert-durch": "SYSTEM",
"unix": 1604406782,
"transaktionsart": "überweisung"
},
};
var data = [];
// Here you have to flat the array
Object.keys(responseData).forEach(function(key){
var value = responseData[key];
data.push(value);
})
$table.bootstrapTable({data: data})
})
</script>
如果您需要此代碼的 ajax 版本,請告訴我。
小提琴http://jsfiddle.net/8ngoh4y1/
添加回答
舉報