Announcement

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

    Search as you type / suggestions

    Hi there,

    Is there already a solution available which will do a server call on every keypress in a text/listitem?

    I'm looking for functionality similar to google's search as you type or suggestions.

    Regards,

    Kees.

    #2
    A combobox with optionDataSource can do similar and you can hide the picker (dropdown) icon.

    Comment


      #3
      Here is a code snippet that I use:
      Code:
      combobox = new ComboBoxItem("username", "Username");
      		combobox.addChangedHandler(new ChangedHandler() {
      			public void onChanged(ChangedEvent event) {
      				do_combobox_onChanged(event);
      			}
      		});
      combobox.setCompleteOnTab(true);
      combobox.setOptionDataSource(userds);
      // can use multiple fields in your pick list
      combobox.setPickListFields(new ListGridField("username", "Username"));
      // value field as primary key in your datasource
      combobox.setValueField("pkey");
      // the display field and ultimately the autocomplete field
      combobox.setDisplayField("username");
      
      // and the handler that will fire when value pkey has changed.
      
      protected void do_combobox_onChanged(ChangedEvent event) {
      	Record record = combobox.getSelectedRecord();
      	if (record != null) {
      	    // check if same record, don want to disable edit on existing
      	    // record.
      	    // possibly check if dynamicForm is dirty and offer to save before
      	    // editRecord( new selected record)
      	    if (currentUser != record) {
      		currentUser = record;
                      // another dynamic form that I will now edit the selected user details
      		dynamicForm.editRecord(currentUser);
                      // disabling save button for my dynamic form as this is newly selected record no edits yet.
                      saveButton.disable(); // default disabled until edit
                      // dynamic form has values so enable it.
      		dynamicForm.enable();
      	    }
              }
      		
      
      }
      I have used this code with nearly a million rows in the table that the datasource links to and it is very quick.

      Comment


        #4
        Is it possible to change the combobox search method to 'LIKE' ?
        when I type, I want the combobox to search 'LIKE' in the item name.

        Comment

        Working...
        X