Hello everyone,
I would like to understand how to setup an IF condition in my table.

For example in my case attached, the decimal of Taker Amount depends on the Taker Tokens.
So let's assume I want to say IF Taker Token ({{ currentRow.order.takerToken}}) is = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 THAN Taker Amount {{ currentRow.order.takerAmount / 1000000000000000000}}.
Currently I'm using "Number" as Column Type, should I use something different so I can put the formula?
Hope is clear, I really need it, thank you to everyone how spend few minutes to answer me.
Bye!
As my understanding I should use the Transformer to create an IF condition in Javascript, am I right?
Hey @abovethecloud, you're right, a transformer is a good way to pass an if
condition in your table. You might want to consider using a ternary operator here. Something like
{{ currentRow.order.takerToken === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ? currentRow.order.takerAmount / 1000000000000000000 : currentRow.order.takerAmount /* you can put whatever alternative you'd like here */}}
Let me know if that helps!
1 Like
Thank you it was helpful! And how to put more conditions? Such as if currentRow.order.takerToken === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" OR " "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" ?
{{ (currentRow.order.takerToken === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" || currentRow.order.takerToken === "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48")? currentRow.order.takerAmount / 1000000000000000000 : currentRow.order.takerAmount}}
You can keep adding using ||
1 Like