I have the following code in my html view:
<td>
<input type="text" style="width: 250px;"
value.bind="selectedStatusCode" list="status_codes">
<datalist name='statusBox'
id="status_codes" style="width: 250px;"
tabindex="5" value.bind="selectedStatusCode">
<option model.bind="null"></option>
<optgroup label.bind="statcode[0]"
repeat.for="statcode of status_code_list"
model.bind="statcode[0]">
<option repeat.for="descr of statcode[1]"
model.bind="descr.statcode_id"
value.bind="descr.statcode_id">
${descr.statcode_id} - ${descr.descr}
(${statcode[0]})
</option>
</optgroup>
</datalist>
</td>
The list object I have is a group of lists.
I need to be able to display the contents in the select of the list of lists in the dropdown like so:
The lists are organized like so:
AR Accounts ,
[ {173, 'back to user'},
{178, 'sent to billing'}.
],
Do Not Use,
[ {500, 'pandemic hold'},
{520, 'billing is complete'},
],
What I am trying to have happen for the dropdown is to display like this:
<optgroup>AR Accounts
<option>173 - back to user </option>
<option>178 - sent to billing</option>
</optgroup>
<optgroup>
Do Not Use
<select>[500 - pandemic hold</select>
<select>520 - billing is complete</select>
</optgroup>
From what I’ve read, <optgroup>
is not supported in datalists, but I don’t know how else to get things to display.
In my code above, I have the name of the outer list (AR Accounts, etc) displaying in parentheses next to the code, but I still get the following in the dropdown:
173
173 - back to user
How can I create this dropdown so that it doesn’t do that?
I did try the following, but it gave me errors everywhere in my code:
<input type="text" style="width: 250px;"
value.bind="selectedStatusCode" list="status_codes">
<datalist name='statusBox'
id="status_codes" style="width: 250px;"
tabindex="5" value.bind="selectedStatusCode">
<option model.bind="null"></option>
<template
repeat.for="statcode of status_code_list"
model.bind="statcode[0]">
<option repeat.for="descr of statcode[1]"
model.bind="descr.statcode_id"
value.bind="descr.statcode_id">
${descr.statcode_id} - ${descr.descr}
(${statcode[0]})
</option>
</tenplate>
Any thoughts would be greatly appreciated.