I have a table cell whose background color is calculated from its value in a JS function. Works well in all cases except when there is only one row with data in that table. In that case every row’s cell gets that color:
@arminus It looks like the table your are using is old version of the Table widget which had a bug. Can you please delete it and create a new table? I’ve created a Debug page in your app to showcase it
Is there a way to do this kind of painlessly? Without having to recreate all the table’s column definitions etc.? And whatever else I might be loosing when deleting the table?
I’d rather argue the other way around. The exported app file is prone to manual errors during editing. Also, you’ll not have a full picture of how the new table obj is suppose to look like. etc.
There’s one more thing - unrelated to the original problem here: While re-testing, I realized there is another issue: The lower right compartment is a iframe which is filled based on the current selection in the master table. This works for a row click (due to master table’s onRowSelected) but that function does not get triggered on page load - although the first row is actually selected.
This might be related to what I brought up back here or maybe not. Question is, how can I trigger a JS function after the upper table is loaded and the default selection is set? I tried adding it to JScrudComment.get like so
It’s not so much about knowing what the default selected row is (it’s 0 by default) but the problem, that although after page load, row 0 is visually selected, Orders.selectedRow is undef until I actually click a row. This is kind of strange.
And since the code and queries of the secondary displays (iframe and table) depend on Orders.selectedRow, they silently fail after page load (-> until I actually click a row in the master/Orders table).
In this case I recommend changing the references to the selected row with a reference to an appsmith store value.
On page load you can set the value to 0
on row selected you can update the value,
in your table and iframe you can reference Orders.tableData[appsmith.store.selectedRowIndex] (assuming you store the value to the key selectedRowIndex. This key can be any name you like.).
This should also update it any time the stored value is updated. Could you try this? Or are there too many references for this to be plausible?