SmartClient Version: SNAPSHOT_v12.1d_2020-02-21/PowerEdition Deployment (built 2020-02-21)
The following code is behaving correctly. It is offering a multiple combo box choices of emails. The data source goes to a SQL table, and looks up the 'FullName' field and retrieves the 'Email 'field. The MultiComboBoxItem displays the full name and uses the email value.
But I want to extend this code to add a number of initial values to the multi combo box. I have a couple of records in an list array, the records comply with the "User_Emails_Proxy" datasource.
List<Record> initEmails = new ArrayList<Record) () =
[ { pk => 10, FullName => 'Minny Mouse' , Email => 'minny@gmail.com' }, { pk => 11, FullName => 'Mickey Mouse', Email => 'mickey@gmail.com' } ]
(excuse the mixed code format, but I think you get the idea).
I have tried
props.setValue( initEmails.toArray() );
props.setValue( initEmails.toArray( new Record[initEmails.size()] );
toFormField.setValues ( initEmails.toArray() )
toFormField.setValues( initEmails.get(0).getAttribute("FullName"))
But this appears to be the wrong approach. What is the correct approach to setting initial values?
I'm aware of this showcase example: https://www.smartclient.com/smartgwt...bobox_category
But I'm not sure of how setting the 'FullName' attribute of the record in the MCBItem will result in it resolving to the Email value.
Suggestions?
The following code is behaving correctly. It is offering a multiple combo box choices of emails. The data source goes to a SQL table, and looks up the 'FullName' field and retrieves the 'Email 'field. The MultiComboBoxItem displays the full name and uses the email value.
Code:
final MultiComboBoxItem toFormField = new MultiComboBoxItem("to"); ComboBoxItem props = new BCMUserBox("none"); props.setShowPickerIcon(false); props.setShowHint(false); props.setShowHintInField(false); props.setHideEmptyPickList(false); toFormField.setTextBoxStyle("textItem"); toFormField.setRequired(true); props.setTextBoxStyle("textItem"); props.setWidth("100%"); toFormField.setWidth("100%"); toFormField.setTitle("To"); toFormField.setTitleAlign(Alignment.LEFT); toFormField.setOptionDataSource(DataSource.get("User_Emails_Proxy")); toFormField.setDisplayField("FullName"); toFormField.setValueField("Email"); toFormField.setComboBoxProperties(props);
List<Record> initEmails = new ArrayList<Record) () =
[ { pk => 10, FullName => 'Minny Mouse' , Email => 'minny@gmail.com' }, { pk => 11, FullName => 'Mickey Mouse', Email => 'mickey@gmail.com' } ]
(excuse the mixed code format, but I think you get the idea).
I have tried
props.setValue( initEmails.toArray() );
props.setValue( initEmails.toArray( new Record[initEmails.size()] );
toFormField.setValues ( initEmails.toArray() )
toFormField.setValues( initEmails.get(0).getAttribute("FullName"))
But this appears to be the wrong approach. What is the correct approach to setting initial values?
I'm aware of this showcase example: https://www.smartclient.com/smartgwt...bobox_category
But I'm not sure of how setting the 'FullName' attribute of the record in the MCBItem will result in it resolving to the Email value.
Suggestions?
Comment