Page 1 of 1

Drop-down list box with constant content

PostPosted: Tue Aug 21, 2018 9:53 am
by ANH
Hello,

I want to put a drop-down list box into a workscreen, with no link to a databook. The values of the list box are a fix set of string literals. I cannot figure out how to do that properly. Could you please help me with this?

Thank you!

Best regards,
Andreas

Re: Drop-down list box with constant content

PostPosted: Tue Aug 21, 2018 10:50 am
by Support@SIB
The doc system has an article for your problem: Custom linked cell editors

Re: Drop-down list box with constant content

PostPosted: Tue Aug 21, 2018 12:45 pm
by ANH
Thank you for your reply.
I still have difficulties to understand how to add the UIEnumCellEditor to a panel or a workscreen. The add-functions require an IComponent as argument, but UIEnumCellEditor is not an implementation of ICompoment.

Re: Drop-down list box with constant content

PostPosted: Tue Aug 21, 2018 1:20 pm
by rzenz
Yes, that is because it isn't a component, it is a cell editor. Cell editors are set on the DataType of the column and then picked up and used automatically by the UIEditors.

See this explanation on what cell editors are for further details.

Re: Drop-down list box with constant content

PostPosted: Wed Aug 22, 2018 10:44 am
by Support@SIB
You could use a DataBook or a Row for the editor, e.g.:

Syntax: [ Download ] [ Hide ]
UIEnumCellEditor cellEditor = new UIEnumCellEditor();
cellEditor.setAllowedValues(new String[] { "A", "B", "C", "D" });
cellEditor.setDisplayValues(new String[] { "Alpha", "Bravo", "Charlie", "Delta" });
               
DataRow row = new DataRow();
row.getRowDefinition().addColumnDefinition(new ColumnDefinition("BASE",
                                           new StringDataType(cellEditor)));

IEditor editor = new UIEditor(row, "BASE");

panel.add(editor);

... and with a DataBook, e.g.:

Syntax: [ Download ] [ Hide ]
IDataBook dataBook = new MemDataBook(rowDef);
dataBook.getRowDefinition().addColumnDefinition(new ColumnDefinition("BASE",
                                                new StringDataType(cellEditor))));
dataBook.setName("BASE");
dataBook.open();

IEditor editor = new UIEditor(dataBook, "BASE");

panel.add(editor);

Re: Drop-down list box with constant content

PostPosted: Wed Aug 22, 2018 11:34 am
by ANH
Thank you. The code examples together with "...and then picked up and used automatically by the UIEditors" made it clear to me.

Best regards
Andreas