valor-software / ng2-table

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

How to Change the color of the row's and the button in-side the each row of the ng-table #528

Open NABEEL-AHMED-JAMIL opened 7 years ago

NABEEL-AHMED-JAMIL commented 7 years ago

I want to add the row's with different color like(red , green) and the button also how i add these both think into the (table config array)

JessyRiordan commented 7 years ago

@NABEEL-AHMED-JAMIL Have you figured out how to do this? I would like to do this as well. Thanks!

NABEEL-AHMED-JAMIL commented 7 years ago

No Dear I'm also Stuck on it.

NABEEL-AHMED-JAMIL commented 7 years ago

Well I'm Working on some other project but I think you should try to used this below description may be it's helpful for you. In html where you put this tag of the table try to used the condition for show color in the tag and in the
onChangeTable() method check the line where he create the row. Check when code create the one row used the condition if row create add the color value in the tag for bind the color. Note: Please try this if you find some positive result than please send the the code Thank's

priyakokas commented 7 years ago

I solved this problem by adding following code in ng-table.components.ts. add style to this td: <td (click)="cellClick(row, column.name, i)" *ngFor="let column of columns" [innerHtml]="sanitize(getData(row, column.name))" [style.color]="getStyle(column.name)" >

make a function in class NgTableComponent public getStyle(propertyName:string) { if(propertyName == "Status"){ return "red"; } else { return ""; } }

Result: Column where name of column is Status is colored.