0
<ngx-datatable
   [rows]="services"
   [columns]="columns">
</ngx-datatable>

I can get this to display nested data with:

{ prop: order.product.price }

How do you do you display a custom calculation in a row? What if I want to apply a fee to the price

{ prop: 'order.product.price + order.fee' }

I guess I would need access to the other values in the row.

Justin
  • 4,203
  • 7
  • 41
  • 58

2 Answers2

1

Use ng-template. For example:

     <ngx-datatable-column name="Order Price+Fee">
        <ng-template let-row="order" ngx-datatable-cell-template>
          <div>{{order.product.price + order.fee}}</div>
        </ng-template>
      </ngx-datatable-column>

I did not test your specific code, But this is one way to do it. Try it and adopt as your requirements

For more info:

Official Documentation templateref

Official Code example

Shanil Fernando
  • 1,302
  • 11
  • 13
1

Unfortunately, ngx datatable seems to be limited with it's prop field in that it doesn't take calculations. I personally got around this by taking advantage of the Typescript accessors. In your case it would be something like

get priceAndFee() { return this.product.price + this.fee; }

... prop="order.priceAndFee" ...

If you think that's cumbersome, that would make two of us.

Michael S
  • 166
  • 2
  • 7