A J Qarshi
A J Qarshi

Reputation: 2992

devextreme - calculate cell value based on another calculated cell

In my Devextreme dependent Angular application, I have four columns (A, B, C, and D) in my dxDataGrid.

C is a calculated column with formula A+B and D is another calculated column that has a dependency on C and the formula is say C*2.

I have used calculateCellValue to calculate the value for C and it works perfectly fine.

However, when I used the same calculateCellValue handler function to calculate the value for column D, it returns an empty cell.

Does this mean we can not define a calculated column that is based on another calculated column?

Upvotes: 1

Views: 833

Answers (1)

marjay
marjay

Reputation: 432

The value for column C you calculate inside the calculateCellValue method does not persist in your data source. Thats why you can't use this value to calculate further. You could do the same calculation in the calculateCellValue method for column D as you did in column C + your extra calculation.

However i would prefer to extend the data source and calculate everything beforehand. This would also improve performance because the calculateCellValue method executes multiple times for each row when rendered, sorted, filtered or summarised.

Upvotes: 0

Related Questions