Add dynamic column to table in smart-table [angularjs]

1k Views Asked by At

I needed a little help over here on adding dynamic columns to table and I'm using smart-table project https://lorenzofox3.github.io/smart-table-website/

Please look at plunker

https://plnkr.co/edit/uTDa6hfwdgGtGWkYqL7S?p=preview

Click on add new column, it will update the table header, but I can't update the td element because I haven't created or binded any td element for new column.

Need help on two things.

1) Any number of new columns might come in future from server dynamically, so I can't bind any element statically in html like I did right now.

2) This is a little long one(I want to create a only one header as MV and in colspan I want current and next) and How do I accomplish that one ? If I divide like that, how do I go frame the data ?

Additional Note on Question 1: I have tried dynamically showing the data in table. please look at line 27 in index.html. But again, If I go with this approach, the values get binded to different different columns since, data's are framed dynamically on controller. To be simple, there is no guarantee that data will be in in this order.

(SNo, companyName, companyFullName, MarketValueCurrent, MarketValueNext, QuarterCurrent, QuarterNext)

companyName might come first or at last. If I go by dynamic looping using ng-repeat, it binds MarketValueNext in first column, then companyName, etc in whichever the order the data is coming.

Thanks in advance.

0

There are 0 best solutions below