valor-software / ng2-table

Simple table extension with sorting, filtering, paging... for Angular2 apps
http://valor-software.github.io/ng2-table/
MIT License
554 stars 336 forks source link

Use a custom cell template #578

Closed BenRub closed 5 years ago

BenRub commented 7 years ago

Hi, I needed the ability to control the HTML in some of my cells. I've edited the NgTableComponent template code and made it check for each column if it has a "template" property. If it has the above, it "sends" the row and the cell content to that template. otherwise, it uses a default template.

This is the code of the feature: https://github.com/valor-software/ng2-table/commit/e483bf2450780f0d570d3295e42964773cdc3983

And this commit shows an example of how to use it: https://github.com/valor-software/ng2-table/commit/aec2ad08a47325cbd5a1717ea090d01db74aca0d

I'm quite new with Angular, so I've tried to make as few changes as possible. Also, I wanted to use the "ng-template" element, but it didn't work, probably because of the angular version. It's easy to change this.

I saw that there are some pull requests for similar issues and they are pending because of a plan to redesign the plugin. However, this commit is very small so, maybe, you could consider pulling it to the main branch.

Thanks, Ben.