Render price from unit_price * quantity on each row while using inline editing

Render price from unit_price * quantity on each row while using inline editing

sven_oliver_simpsonsven_oliver_simpson Posts: 3Questions: 2Answers: 0

Hi,

my mysql database has 2 columns: quantity and unit_price. Using inline editing it can be directly updated.
The DataTable should have a third column showing the price for each row calculated from quantity*unit_price and it should be updated whenever I change quantity or unit_price using inline editing.
How is the best way to implement this?

Thanks

SOS

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    The best way typically is to use columns.render. Set the columns.data option for the column to null and then use a function for the renderer. For example:

    {
      data: null,
      render: function ( data, type, row ) {
        return row.quantity * row.unit_price;
      }
    }
    

    Allan

  • sven_oliver_simpsonsven_oliver_simpson Posts: 3Questions: 2Answers: 0

    Works. Thanks

This discussion has been closed.