arrow_back history picture_as_pdf This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ~~NOTRANS~~ ~~Title: Custom Linked Cell Editors (Dropdown, Picklist)~~ With JVx, it's very easy to define dropdown list boxes, LOVs, or picklists. JVx supports manual definition or automatic definition of dropdowns. If you want to use automatic dropdowns, read the following: [[jvx:client:model:databook:autolistboxes|Automatic List Boxes based on the DB Model]]. If you want to define custom dropdowns, continue reading. JVx offers different options with or without database. === UIEnumCellEditor === The easiest solution is an UIEnumCellEditor. <file java> UIEnumCellEditor cellEditor = new UIEnumCellEditor(); cellEditor.setAllowedValues(new String[] {"A", "B", "C", "D"}); cellEditor.setDisplayValues(new String[] {"Alpha", "Bravo", "Charlie", "Delta"}); </file> The cell editor saves an allowed value and displays a display value. After the definition, set the cell editor to the datatype of a specific column. <file java> dataBook_or_row.getRowDefinition().getColumnDefinition("VALUE"). getDataType().setCellEditor(cellEditor); </file> Use an IDataBook or IDataRow. An IDataBook is, for example, the MemDataBook or the RemoteDataBook. An IDataRow is, for example, the DataRow. It's possible to create a DataRow from an existing IDataBook, e.g.: <file java> IDataRow row = baseDataBook.createEmptyRow(new String[] {"LINK_ID", "LINK_VALUE"}); </file> or to create a new DataRow. <file java> RowDefinition rowdef = new RowDefinition(); rowdef.addColumnDefinition(new ColumnDefinition("LINK_ID", new BigDecimalDataType())); rowdef.addColumnDefinition(new ColumnDefinition("LINK_VALUE")); DataRow row = new DataRow(rowdef); </file> To use automatic translation, follow [[jvx:client:model:databook:recordtranslation|these instructions]]. === UILinkedCellEditor === If you need more flexibility, use an UILinkedCellEditor for your dropdowns. The UIEnumCellEditor maps a value to one ID column and displays the value column. The UILinkedCellEditor shows one or more columns and maps multiple ID columns. The cell editor needs an IDataBook which contains the data. Use a MemDataBook or a RemoteDataBook. Our example uses a MemDataBook. <file java> RowDefinition rowdef = new RowDefinition(); rowdef.addColumnDefinition(new ColumnDefinition("ID", new BigDecimalDataType())); rowdef.addColumnDefinition(new ColumnDefinition("VALUE")); MemDataBook memBook = new MemDataBook(rowdef); memBook.setName("memory"); memBook.open(); UILinkedCellEditor linkCellEditor = new UILinkedCellEditor(); linkCellEditor.setLinkReference(new ReferenceDefinition( new String[] {"LINK_ID", "LINK_VALUE"}, memBook, new String[] {"ID", "VALUE"})); dataBook_or_row.getRowDefinition().getColumnDefinition("LINK_VALUE"). getDataType().setCellEditor(cellEditor); </file> We map the ID to LINK_ID and VALUE to LINK_VALUE. The VALUE column will be shown in the dropdown. After selecting a value, the ID and VALUE will be written to LINK_ID and LINK_VALUE. You can use the UILinkedCellEditor with a RemoteDataBook and read record from a remote storage, e.g., a database, a XML file, CSV file, or any other datasource. You don't need a specific datasource if you use a MemDataBook.