如果使用javascript源数据构建表,如何向表中添加子行?
我没有在这里复制我的所有html /脚本,我只需要知道如何在每个现有行下面添加另一行,这些行将跨越父行中的单元格。
var lenders = [{
Lender: "Bank 1",
Amount: ["100"],
Term: [30, 60],
stuff: 'foo'
}, {
Lender: "Bank 2",
Amount: ["250"],
Term: [60],
stuff: 'bar'
}, {
Lender: "Bank 3",
Amount: ["100", "250"],
Term: [30],
stuff: 'baz'
}, {
Lender: "Bank 4",
Amount: ["100"],
Term: [60],
stuff: 'qux'
}, {
Lender: "Bank 5",
Amount: ["250"],
Term: [30],
stuff: 'fgfd'
}, {
Lender: "Bank 6",
Amount: ["100", "250"],
Term: [30, 180],
stuff: 'done'
}];

答案 0 :(得分:0)
很容易,在索引1处添加新项目:
lenders.splice(1, 0, newRowObject);