Announcement

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

    Get records from combobox option ds

    Hello,

    The story is this: I want to create a dynamic suggestion/autocomplete feature to a comboboxitem.
    In this item i have setted a ds with which i fetch data when the keypress event is triggered. Also i have setted the comboboxitem's setFilterLocally and setUseClientFiltering to true. The method i use to fetch data is usernameComboBoxItem.fetchdata(DSCallback). Inside the callback i want to get the records that where returned from the ds but i get null instead. I have added the code below

    Thanks in advance

    Code:
    ComboBoxItem usernameItem = new ComboBoxItem("usernameField",
                    "Username");
    usernameItem.setAutoFetchData(false);
            usernameItem.setFilterLocally(true);
            usernameItem.setUseClientFiltering(true);
    usernameItem.addChangedHandler(new ChangedHandler() {
    
    @Override
    public void onChanged(ChangedEvent event) {
    ComboBoxItem userNameItem = (ComboBoxItem) event.getItem();
    if (userNameItem.getOptionDataSource() != null)
         userNameItem.getOptionDataSource().destroy();
    
    userNameItem.setOptionDataSource(
        new GetSearchUserDS(event.getValue().toString(),ServerNames.getDefault().getName()));
    
    userNameItem.fetchData(new DSCallback() {
    
                            @Override
                            public void execute(DSResponse dsResponse, Object data,
                                    DSRequest dsRequest) {
    
                                GWT.log(dsResponse.getDataAsString());
                            }
                        });
    Last edited by e.kousou; 14 Jul 2016, 07:53.

    #2
    Hello, Has anyone any idea about the issue above?

    Thanks in advance

    Comment


      #3
      Hi e.kousou,

      why don't you just set an optionDataSource on the ComboBoxItem? Do so outside the ChangedHandler (it is a one time setting) and leave the ChangedHandler away at all.

      Best regards
      Blama

      Comment

      Working...
      X