01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.combo;
09:
10: import com.gwtext.client.data.SimpleStore;
11: import com.gwtext.client.data.Store;
12: import com.gwtext.client.widgets.Panel;
13: import com.gwtext.client.widgets.form.ComboBox;
14: import com.gwtext.client.widgets.form.FormPanel;
15: import com.gwtext.sample.showcase2.client.SampleData;
16: import com.gwtext.sample.showcase2.client.ShowcasePanel;
17:
18: public class ComboBoxCompactSample extends ShowcasePanel {
19:
20: public String getSourceUrl() {
21: return "source/combo/ComboBoxCompactSample.java.html";
22: }
23:
24: public Panel getViewPanel() {
25: if (panel == null) {
26: panel = new Panel();
27:
28: final Store store = new SimpleStore(new String[] { "abbr",
29: "states" }, SampleData.getStates());
30: store.load();
31:
32: ComboBox cb = new ComboBox();
33: cb.setMinChars(1);
34: cb.setFieldLabel("State");
35: cb.setStore(store);
36: cb.setDisplayField("states");
37: cb.setMode(ComboBox.LOCAL);
38: cb.setEmptyText("Enter State");
39: cb.setLoadingText("Searching...");
40: cb.setTypeAhead(true);
41: cb.setSelectOnFocus(true);
42: cb.setWidth(200);
43: //do not show drop fown icon
44: cb.setHideTrigger(true);
45:
46: FormPanel form = new FormPanel();
47: form.setLabelWidth(35);
48: form.setBorder(false);
49: form.add(cb);
50:
51: panel.add(form);
52: }
53: return panel;
54: }
55:
56: public String getIntro() {
57: return "<p>This is an example of a compact ComboBox where there is no drop down icon. This is done by calling setHideTrigger(true) on the ComboBox.</p>"
58: + "<p>As the user types in the ComboBox field, the ComboBox options are displayed.</p>";
59: }
60: }
|