Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    incorrect item selected from PickList of ComboBoxItem

    Hi,

    We are using GWT 1.7.1 and SmartGWT 2.4. We are experiencing a problem with the PickList value selected from ComboBoxItem. This problem occurs on all web browsers we tested (IE, GWT's default browser, and FireFox).

    Our data source for the PickList is defined as follows:
    <DataSource
    ID="stock"
    serverType="generic">
    <fields>
    <field name="stockKey" type="sequence" hidden="true" />
    <field name="description" type="text" hidden="true" />
    <field name="market" type="text" title="Market" width="60" />
    <field name="currency" type="text" title="Currency" width="65" />
    <field name="symbol" type="text" title="Symbol" width="60" />
    <field name="cusip" type="text" title="CUSIP" width="100"/>
    <field name="ISIN" type="text" title="ISIN" width="100"/>
    <field name="sedol" type="text" title="SEDOL" width="100"/>
    <field name="name" type="text" title="Stock Name" width="250" />
    </fields>
    <operationBindings>
    <binding operationType="fetch" serverMethod="fetchStocks">
    <serverObject lookupStyle="spring" bean="preTradeService"/>
    </binding>
    </operationBindings>
    </DataSource>


    and our ComboBoxItem is defined as:
    ListGridField nameField = new ListGridField("name", 250);
    ListGridField marketField = new ListGridField("market", 80);
    ListGridField currencyField = new ListGridField("currency", 80);
    ListGridField symbolField = new ListGridField("symbol", 80);
    ListGridField cusipField = new ListGridField("cusip", 80);
    ListGridField ISINField = new ListGridField("ISIN", 100);
    ListGridField sedolField = new ListGridField("sedol", 80);

    final ComboBoxItem stockItem = new ComboBoxItem("Stock");
    stockItem.setPickListWidth(750);
    stockItem.setWidth(500);
    stockItem.setOptionDataSource(DataSource.get("stock"));
    stockItem.setAutoFetchData(true);
    stockItem.setShowAllOptions(true);
    stockItem.setRequired(true);
    stockItem.setPickListFields(symbolField, nameField, marketField, currencyField, cusipField, ISINField, sedolField);
    stockItem.setDisplayField("name");
    stockItem.setPickListCriteria(new Criteria("Global", Boolean.toString(getUser().isGlobal())));
    stockItem.setDefaultToFirstOption(Boolean.TRUE);
    stockItem.addChangedHandler(new ChangedHandler(){
    public void onChanged(ChangedEvent event) {
    ListGridRecord record = stockItem.getSelectedRecord();

    When the PickList was populated with multiple items with identical name (nameField), regardless of the user's selection, the first item was always returned as the selected item (while other fields of the items are not identical).

    I tried to change the name of the field to searchString instead of name, then tried setDefaultToFirstOption(false), but I had no luck. Would anyone please kindly point us in the right direction?


    Thanks in advance.

    #2
    You should set valueField to something that uniquely identifies the record (typically, it's primary key). Otherwise the ComboBox has no way to store a value that actually identifies the selected record.

    Comment


      #3
      Yes, I added a hidden field to serve as an unique identifier, and this issue was resolved.

      Thank you.

      Originally posted by Isomorphic
      You should set valueField to something that uniquely identifies the record (typically, it's primary key). Otherwise the ComboBox has no way to store a value that actually identifies the selected record.

      Comment

      Working...
      X