I have a table component pulling in data from a postgres database. One of the columns i'm pulling in called "Cost" is a dollar amount. I have two more columns in the table component that allow me to add a percentage markup to the Cost. The other two columns are "Markup" which is a percentage type that can be edited and the other column is "Total" which is the final computed amount from the Cost column multiplied by the Markup column. The total column has a mapped value of:
The problem is when I run a save action query (to update the database) with the computed column data. Do i need to create a transformer or something and not use GUI mode for the update query?
I guess there's a few things not working as needed. First off, I changed the table name from table37 to reconcileExpenses.
My mapped value for the Total column isn't calculating in real time when i update the Markup column. When I run the updateExpenses query it all works, but the Total column doesn't get added to the database table because it's a mapped value?
Here's the mapped value for the Total column:
Sorry @dru_nasty, but I don't know a local way to solve this problem. Inserting a transformer or changing the data in the update query may be a solution. But I think these are not what you are looking for.
Thanks for that, i'm still really stuck on the fact this mapped value doesn't update my total column in real time. Only after running a save as query on the table and updating the database.
So it's still two issues: 1) Can't see mapped value updates in real time on the table after changing data. 2) The total column data isn't saved to the database.
And now it doesn't match up with the current row i have selected.
I'll select a row and check the values and the values are all from a totally different row.
My primary key id's are all unique.
I get an error of "Primary key expense_id is not present in supplied array."
Doesn't matter if ia set the primary key to expense_id on my table component either, i get the same error. Only when I do that then my total column doesn't not update the value in real time.
Maybe this explains it better, i changed the 2nd row markup to 10%. Nothing changes.
When i hover over currentsourceRow.cost in the mapped value, it shows 10 (which is the cost value for the first row in the table). Something not lining up for some reason. Apologies for not following or being able to explain.
It doesn't work because there is a mistake. You try to find id of changesetArray but you don't have any id property on your table. You have expense_id property on it.
Just try to replace: _.find(..., id: currenctSourceRow.expense_id with _.find(..., expense_id: currenctSourceRow.expense_id
Are you sure you checked Include full rows in changeset array property of table? You can't update your data without primary key. It's normal to get an error.
For the update query, using the following: (having to omit a column that has some mapped data, not source data, that I want to exclude from the update):