How can I make a select the value of a field in the Data Store

I have a repeat region with select boxed for Category & Sub Category.
When the Sub Category is selected, it runs a flow which adds the prodID, cat, sub_cat, mup, to the data store.
Now what I am trying to achieve is if someone has to come off the page then the selected value for cat & sub_cat is got from the Data Store.

I’ve tried as the selected value in the select:

updates.data.cat.where(prodID, prodID, ‘==’)

&

updates.data[0].cat.where(prodID, prodID, ‘==’)

but this has not worked.

Would anyone have any idea how or if this can even be done?

You need tick quotes around the field name ‘ProdID’ -> ProdID

OK I worked it our finally :slight_smile:
Code that works is:

<select id="select_cat" dmxbind:id="select_cat_{{[$index]}}" class="form-select" dmx-bind:options="category.data.query_category" optiontext="cat_name" optionvalue="cat_id" dmx-bind:value="updates.data[$index].cat">
                            <option value="">Select</option>
                        </select> 

It seems that I forgot to bind the ID and it was easier to use the index…assuming that the order is kept correct when altering (eg, 1,2,3,4)

You need to use:

dmx-bind:value="updates.data.where(`prodID `, prodID, '==')[0].cat"

ok I will give that a try, it may be better that what I just got working. :slight_smile:

perfect, worked first time…and I can see the logic behind the code as well :slight_smile: learning something new each day

1 Like