Announcement

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

    ComboboxItem search filter stops working after first key press

    SmartGWT 5.0-p20150906. I have been scratching my head on this all night now, so i give up and hope that i can get some pointers here...

    I have a comboboxitem i'm using to filter a listgrid. The code to create it is like this:
    Code:
    comboBox = new ComboBoxItem(displayFieldToUse, title);
    comboBox.setValueField("id");
    comboBox.setDisplayField(displayFieldToUse);
    comboBox.setOptionDataSource(ds);
    comboBox.setAutoFetchData(true);
    comboBox.setAddUnknownValues(false);
    comboBox.setWidth(100);
    It works fine, and the dropdown is populated from the datasource i specify as optiondatasource.

    However, say there are 20 items. I start typing 'p' and it filters correctly, so that only 2 items are displayed. I then type another 'p' - and all 20 items are displayed again! If i erase all text and start over, nothing happens, all items are displayed. If i reload the page, i can do the same thing again - after the first keypress, all items are displayed.

    I'm out of ideas. Anybody have any clue as to what i might be doing wrong?

    #2
    Sounds like a mismatch between client-side and server-side filtering. The server returns the results filtered to 2 items. For the next keystroke, client-side filtering is active, and is possibly failing because the returned records do not actually contain values for the displayField, or have them under the wrong field name, etc.

    Comment


      #3
      I just found it. In the layout class where this combobox is used, i add a criteria that i want to be sent to the server always, in order for only "enabled" records to be fetched. This works, but apparently has the side-effect that i describe. If i remove it, it starts working, but the dropdown then contains disabled rows.

      Code:
      AdvancedCriteria enabledFilter = new AdvancedCriteria(new Criterion("enabled", OperatorId.EQUALS, true));
      comboBox.setOptionCriteria(enabledFilter);
      This is so that i in my Spring Bean on the server know if i should return all or just the enabled records:
      Code:
      Boolean enabled = (Boolean)request.getCriteriaValue("enabled");
      I'm not sure that i understand why this screws up the search in the client...
      I use the "enabled" criteria on the server, so all rows returned will have enabled=true. I'm not sending nor using the typed text search on the server.

      EDIT: Doesn't matter what i set in the advancedcriteria. i can set "banana" equals "orange", i still get the same behaviour in the client.
      Last edited by mathias; 16 Sep 2015, 14:34.

      Comment


        #4
        You can turn on the "ResultSet" log category to see when client vs server filtering is taking place, and with what criteria. See anything wrong, such as the text filtering being dropped on the client request that ends up showing all records?

        Comment

        Working...
        X