Announcement

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

    ComboBoxItme live search

    Hi guys,

    is there a ComboBoxItem live search function in SmartGwt? In my project there will be a large number of addresses in the database, the user needs to pick one up from them.

    I know ComboBoxItem can do a search when type in, but it works after all records are loaded into the combo box, doesn't it? due to the huge amount of data, it's not a good idea to load them all into the combo box.

    Is there any way that can do a database search while user type in to the combo box, and show relevant entries in the box?

    Thanks!

    #2
    After a bit research and test, i get it done this way:

    Code:
    		comboPickupAddress.setValueField("address");
    		comboPickupAddress.setDisplayField("address")
    		comboPickupAddress.setOptionDataSource(dsPickupAddress);
    		comboPickupAddress.addChangeHandler(new ChangeHandler() {
    			public void onChange(ChangeEvent event) {
    				String val = (String)comboPickupAddress.getValue();
                    Criteria criteria = new Criteria("address", val);
    				comboPickupAddress.setOptionCriteria(criteria);
    			}
    		});
    this way when typing in the combo box, it searches based on the characters, and load the addresses matching the criteria. Hi Iso, is this the right way of doing it? will it cause too many sever/database calls?

    One problem is how i can pop up the suburb, state, and post code columns into other TextFieldItem? It looks that the combo box fetch is done behind the scene, how to get the DSResponse and the table data?
    Last edited by ledais0802; 21 Oct 2010, 21:06.

    Comment

    Working...
    X