I have a combobox that is tied to a command driven sequence A_COMMAND. At various time I would like to disable some of the selections (I have 6 total).
I would like to disable some of the selections a permitted condition is not met.
Is this possible?
I am trying to avoid creating multiple comboboxes with different visibility animations
Thanks,
Yes this is possible by not adding the Commands you want disabled, Not sure what you logic is to populate your combobox but here is an example of the OnClick Interaction on the Combobox named cmbCommand for a ContextualDisplay and only showing the commands that are ENABLED.
const entries = (Dsp.cmbCommand.Entries as Array<any>); entries.length = 0; let module = Dsp.Tag; let nsOptions = await DLSYS.ReadAsync(`${module}/A_COMMAND`).then(async rtNamedSet => { // get the named set let nsOptions = Object.values(rtNamedSet.Value.Options); // get the options of the namedset nsOptions = nsOptions.filter(option => option.Flags.Number & 1); // get the selectable options only (i.e. flag bit 1) let readers = nsOptions.map(async option => { // get a reader to retrieve enabled option let enabpath = `${module}/COMMAND_${String(option.Number).padStart(5, '0')}/ENABLED.CV`; let enab = await DLSYS.CondReadAsync(enabpath, false); if (enab) { entries.push({ DisplayName: option.Text, Value: option.Number.toString( ), }); return option; } else { return null; } }); nsOptions = await Promise.all(readers); // parallel await results nsOptions = nsOptions.filter(option => option !== null); // omit the null values return nsOptions; });
Note: Because this only runs when you click, if you have the possibility of the Enable changing dynamically you will need to have a timer running and run the same script on timeout to ensure your selections are still valid.