Should work in my mind have you tried adding a toNumber
before the sum? or linePrice.toNumber()
Hey Paul, yes tried the old .toNumber()
trick to no avail.
The hidden inputs are receiving a value, checked that with DevTools. I also tried a sum inside of the repeat just to see if it was a problem with retrieving a value outside of the repeat but that failed too.
Try
<p>{{ddPrice.data.price_nonmembers.toNumber()}}</p>
or
<p>{{price_nonmembers.toNumber()}}</p>
or
<p>{{ddPrice.data.price_nonmembers.toNumber().formatCurrency("£", ".", ",", "2")}}</p>
or
<p>{{price_nonmembers.toNumber().formatCurrency("£", ".", ",", "2")}}</p>
to see which one give a result
If I take it directly from my data source then it is easy with
{{serverconnect1.data.folderList1.sum(`size`)}}
but trying to get it from the results inside a repeat is proving to be a little more tricky, will carry on trying a few things and let you know.
Thanks guys, I’ve done similar in the past with server-side data but it’s the first time trying data from data store and in a repeat. I’m going to try using a table instead to see if that makes any difference
@psweb and @UKRiggers are already helping. But if you look at this link, you can find similar explanations.
Thanks @s.alpaslan I had seen that article.
I’ve now stripped everything down to basics, a form which contains a repeat based on datastore data. For every item in the datastore it repeats a row.
Each row contains two fields, filmID and lineQty, both of which are currently number fields.
<form id="cartForm" method="post" is="dmx-serverconnect-form" action="dmxConnect/api/order/checkout.php">
<div class="row" is="dmx-repeat" id="rCart" dmx-bind:repeat="cart.data">
<div class="col-12">
<div class="row">
<div class="col">
<input id="filmID" name="filmID" type="text" class="form-control" readonly dmx-bind:value="film_id" dmx-bind:name="record[{{$index}}][filmID]">
</div>
<div class="col">
<input id="lineQty" name="lineQty" type="text" class="form-control" readonly dmx-bind:value="qty" dmx-bind:name="record[{{$index}}][lineQty]">
</div>
</div>
</div>
</div>
</form>
Further down on the page I am trying to SUM the lineQty fields, so I use;
{{cartForm.data.repeat1.sum(`lineQty`)}}
Which doesn’t return anything. I’ve also tried the following combinations with no luck.
{{cartForm.data.repeat1.sum.toNumber(`lineQty`)}}
{{cartForm.data.repeat1.sum.toNumber()(`lineQty`)}}
{{cartForm.data.repeat1.sum(`lineQty`).toNumber()}}
you have wrong id in repeater so it must be dmx-bind:id="‘lineQty’+$index"
<input id="lineQty" name="lineQty" type="text" class="form-control" readonly dmx-bind:value="qty" dmx-bind:name="record[{{$index}}][lineQty]">
and why do you have 2 name attributes. ?? I think you missed it.
use only dmx-bind:name (dynamic) if you are using it inside repater
Thanks, now changed to:
<input dmx-bind:id="‘lineQty’+$index" type="text" class="form-control" readonly dmx-bind:value="qty" dmx-bind:name="record[{{$index}}][lineQty]">
But still no result
Gave that a try Neil but no output either
I’m not sure if this is relevant but as you’re using a data store, could Generated Columns be what you’re missing?
Thanks Tom but I’m using a Form and then a repeat to show the data from datastore, and then I was hoping to run a SUM of all of the values, i.e lineQty fields to show a total.
This seems harder than it should be
you miss a few things. For example your repeater id rCart but you use form id instead.
you can use the console for correct syntax .
dmx.app.data.cartForm.rCart.items
you can see the all items on console .
so this is wrong -> cartForm.data.repeat1
Life will be easier if you use a datastore component.
Like this…?
Done with Data Store and repeats, with a sum.
It’s not finished so forgive it for not clearing the form upon item additions
I’m off out for a little while so may not reply straight away.
yes that’s exactly what i want to tell.
Yes very similar to this but without the onClick event and for multiple fields pre-filled by a datastore repeat…
Info in this thread might help. I have never got sum expression worked out using the expression builder, just coded it…