1 回答

TA貢獻(xiàn)1909條經(jīng)驗 獲得超7個贊
可以觀察到的是,您不知道密鑰,因為它是動態(tài)的。您可以做的是進(jìn)行 ajax 調(diào)用并獲取變量中的數(shù)據(jù)。現(xiàn)在您必須平坦響應(yīng),以便可以將平坦數(shù)組傳遞到 Bootstrap 表。您不使用data-url屬性,而是遵循 fiddle 中給出的過程
我添加了一個小提琴,您可以將其用作示例。我還添加了適當(dāng)?shù)脑u論。
超文本標(biāo)記語言
<link href="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.css" rel="stylesheet">
<script src="https://unpkg.com/bootstrap-table@1.18.0/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>
你的腳本應(yīng)該是
<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/
添加回答
舉報