This was not pointed out in the docs on the new Options List, but is the most powerful capability of the new feature as far as I am concerned.
Here is a use case of mine. I have a dropdown for selecting which invoice to work on. I now need to find a way to remember that invoice's row data to use in the app. Here are all of the ways I have tried to do this in various apps:
-
Set the InvoiceId in a temp var from the click event. Then run a query on the invoices table to just get that one record. I can then refer to that query everywhere in the app like this:
qryInvoices.data.invoiceDate[0]
. (Don't forget the [0]). -
A shortcut to the above is to just use mySelect.value in the query.
-
Get the selected row column values by referring to the
mySelect.selectedIndex
as in:qryInvoices.data.invoiceDate[mySelect.selectedIndex]
-
Similar to the above you can use the
mySelect.value
as in:qryInvoices.data.invoiceDate.find(e => e.Invoice_Id === mySelect.value)
-
A variation on the previous 2 is to store the row in a temp var from the Select's Click event:
currentInvoiceRow.setValue(qryInvoices.data.invoiceDate[mySelect.selectedIndex])
. Then you can read the row withcurrentInvoiceRow.value.invoiceDate
.
I believe there is a new best practice for this which deprecates all of the above methods. You can use the query.data as the source for components that use the Mapped mode of the new Options List feature, like the Select.
- Set the Data Source to your query
- Set your Value and Label as appropriate (e.g. {{ item.invoice_Id }} and {{item.customer_name}})
- Now you can easily get to all of the columns in the selected row like so:
mySelect.selectedItem.invoiceDate.
No more extra wiring is needed.