fin-hypergrid / core

A canvas-based super high performant grid renderer API
MIT License
897 stars 144 forks source link

Can column calculator do a chain update? #787

Closed slimtom95 closed 5 years ago

slimtom95 commented 5 years ago

Suppose we have columns & their column calculators like these:

column A which is calculated from column A1 A2 A3 column B which is calculated from column B1 B2 B3 column C which is calculated from A & B

and A1 to B3 they are just some plain columns. While A and B working fine, C is ignoring the calculated result of A and B. Instead, it simply takes the underlying plain value into its own calculation.

I think I can always wrap the whole calculation logic to replace chain update, but is there any elegant ways to achieve a real chain update?

joneit commented 5 years ago

Correct, the results are not saved anywhere; it would be inefficient to run the calculators again.

However, there is a...

Work-around

In the first two calculator functions, store the result into a "hidden" column in dataRow and then reference that hidden column from the final calculator. Columns created in this way would be completely unknown to Hypergrid or the data model's schema.

slimtom95 commented 5 years ago

Amazing, the hack works.

Now when I computing A and B, I also save a A_tmp & B_tmp (columnName finally usable here) And when computing C, just refer them like A_tmp || A.

Thank you joneit!