Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

MultiComboBoxItem: setting values pragmatically

$
0
0
Hello,
I am using SmartGWT 4.1 and Firefox 25.0.1

I am trying to set the value of MultiComboBoxItem from a user input pragmatically and keeping the old value of it.

the setValues function is not updating the MultiComboBoxItem value and it does not reflect the changes.

Here is a snippet of the code (I could not attach the project that reproduce the problem due a server error from your side).

Code:



        final CompanyComboBox concepts = new CompanyComboBox();
                final DynamicForm conceptsForm = new DynamicForm();
               
                final TextItem item=new TextItem();
                conceptsForm.setFields(concepts,item);
                this.addMember(conceptsForm);
               
                Button button=new Button("Add New KPI");
               
                button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                       
                        @Override
                        public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
                       
                                String[] values = concepts.getValues();
                                final String[] newValues=new String[values.length+1];
                                int j=0;
                                for (int i = 0; i < values.length; i++) {
                                        String string = values[i];
                                        newValues[j]=string;
                                        j++;
                                       
                                }
                                newValues[values.length]=item.getValueAsString();
                       
                       
                                concepts.setValues(newValues);
                        }
                });
                this.addMember(button);

Code:


public class CompanyComboBox  extends MultiComboBoxItem{

       
        final MultiComboBoxLayoutStyle initialLayoutStyle = MultiComboBoxLayoutStyle.VERTICAL;
        public CompanyComboBox(){
                super();
                this.setTitle("Comapny");
                this.setOptionDataSource(new CompanyListDataSource());
                this.setDisplayField("orgLabel");
                this.setValueField("orgLabel");
                this.setLayoutStyle(initialLayoutStyle);
                this.setShouldSaveValue(true);
                this.setAlwaysFetchMissingValues(false);
                this.setAutoFetchData(true);
               
               
        }
}


Viewing all articles
Browse latest Browse all 4756

Trending Articles