简体   繁体   中英

Adding a child row to a javascript sourced data table

How do you add a child row to a table if the table is constructed using javascript sourced data?

I have not copied all of my html/script here, I just need to know in general how you would add another row below each existing row that will span the cells in the parent row.

 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' }]; 

很容易,在索引1处添加新项目:

lenders.splice(1, 0, newRowObject);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM