I am trying to have a combination table that displays both data from a collection and calculated data. This calculated data is at runtime and will never be stored anywhere.
So on the dynamic page ingredients are displayed as well as their amounts. This all comes from a collection. However I want to be able to alter these numbers (and the units) to have both a base amount and a display amount. The display amount will be based on a user input on the screen.
Apologies for this being messy but I am trying a few different things I have found in other posts but nothing seems to have worked. Right now I am just trying to manually set the column to some junk data. The “row” populates as I would expect and has the full amount of data needed
function changeServing() {
var servings = parseInt($w( ‘#servings’ ).text, 10 )
if ($w( ‘#myServings’ ).value !== servings) {
var servingFactor = $w( ‘#myServings’ ).value / servings
$w( ‘#ingredientTable’ ).rows.forEach((row, i) => {
row[ “displayAmt” ] = “5”
console.log(row)
$w( ‘#ingredientTable’ ).updateRow(i,row)
$w( '#ingredientTable' ).rows[i][ "displayAmt" ] = 5
//console.log(ingredientTable.rows[i])
})
}
}
_id: “467e6a41-f5e8-4130-95c0-1a271351a0fb”
_owner: “27029325-979f-45d7-bfad-48c14613cc8f”
_createdDate: “2020-09-18T23:06:16.370Z”
ingredient: {…}
_updatedDate: “2020-09-18T23:06:32.914Z”
amt: 1
unit: {…}
meal: “b801c238-65a4-4a63-8a37-750b6a2c9f86”
displayAmt: “5”
This however does work but deletes everything else
$w( ‘#ingredientTable’ ).updateRow(i,{displayAmt,5})
Can I not use the row object that was created to do an updateRow?
What am I missing?
I have tried a couple other things as well but they haven’t worked. I tried looking into hooks as well but it doesn’t seem like it would work here.