Table Cell Conditional Text Color

  • Goal: Set text color based on source or changed values

  • Steps: I've tried setting the text by comparing item (what I believe should be the current value) to a value. It works fine when the data is loaded, but not when a value is changed by the user

  • Details: Using Table (New) with mapped column of format currency.
    Simple example of Text property: {{ +item > 0 ? 'red' : 'blue' }}

  • Screenshots:
    on Screen Load:
    Screenshot 2024-07-08 at 11.15.46 AM

After updating values
Screenshot 2024-07-08 at 11.18.16 AM

I've seen the similar topics that had said this was fixed some time ago, but at the moment it does not seem to be working for me at least

Does it work after you save the changes?

Yeah, if the backend db gets updated and the data refreshed, it does show the correct format. But one way I'm trying to use it is to warn the users of certain things before they would save

If you just need to show a different color for the changed cells you could link the changesetArray's PK to the currentRow's PK value and then ALSO check for the column's key in the changesetArray/Object.

Something a little like:

{{ table3.changesetArray.filter(entry => entry['Your PK'] === (currentSourceRow['Your PK'])).length > 0 ? 'red' : null }}
1 Like

So as far as I can tell, the issue is just that 'item' doesn't change when changes are made. I assumed it was the current value in the cell. Is there another variable in context that is the current value? For now I'll do what @pyrrho suggested, and look up the changeset every time

Unfortunately, not as far as I know.

The 'items' in your table are all from a source data set. When you edit the cells in the table, none of the source data is changing unless you save/update the changes back to the source. The changesetArray/changesetObject is the only thing in this context where you get the 'current' value of an item that is different than the source data.

Thank you.
Off-topic, but do you know if there is there a way to merge the changeset into the source data, such that we don't have to refresh the entire table every time? Or perhaps send the update, and only get a refresh of the changed rows and merge them?

Refreshing the table with the latest data is kind of unavoidable if you need to be changing that data.