Ngx-datatable: Different cellTemplate for each row

Created on 25 Sep 2017  路  5Comments  路  Source: swimlane/ngx-datatable

[ ] bug report => search github for a similar issue or PR before submitting
[ X ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
```

Current behavior
Today I set the cellTamplate for each column.

Expected behavior
I'd like to set a specific [routerLink] for each cell in specific column for each row.

What is the motivation / use case for changing the behavior?
Each cell for the Name column should have a cell template with different href or different [routerLink] for each row.

Please tell us about your environment:

  • Table version: 0.8.x

  • Angular version: 2.0.x

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Most helpful comment

@nssantos I was just in the process of typing this:

you can use let-row="row" to get access to the entire row data like this below:

<ngx-datatable-column name="Name">
      <ng-template let-value="value" let-row="row" ngx-datatable-cell-template>
            Hi: <strong>{{value}}</strong>
            <a href="{{row.anyRowVariable}}">{{row.anotherRowVariable}}</a>
      </ng-template>
</ngx-datatable-column>

All 5 comments

I covered that using the (active) callback function. There aways the mouse enter on line, I change the template href based on the row entity I'm currently on.

@nssantos I was just in the process of typing this:

you can use let-row="row" to get access to the entire row data like this below:

<ngx-datatable-column name="Name">
      <ng-template let-value="value" let-row="row" ngx-datatable-cell-template>
            Hi: <strong>{{value}}</strong>
            <a href="{{row.anyRowVariable}}">{{row.anotherRowVariable}}</a>
      </ng-template>
</ngx-datatable-column>

@wizarrc Thank you. Your comment prevented me to use a lot of workaround to do a simple task.
Where in the docs or in demos I can see some explanation about that?

@nssantos I just looked in the actual source code here. Probably should add some documentation on that. As for demo examples, just search in here ngx-datatable-cell-template and you should see many demo pages.

Also, this example may help. It has more details about what @wizarrc mentioned in his reply

Was this page helpful?
0 / 5 - 0 ratings