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.core.Template;
11: import com.gwtext.client.data.SimpleStore;
12: import com.gwtext.client.data.Store;
13: import com.gwtext.client.widgets.Panel;
14: import com.gwtext.client.widgets.form.ComboBox;
15: import com.gwtext.client.widgets.form.FormPanel;
16: import com.gwtext.sample.showcase2.client.SampleData;
17: import com.gwtext.sample.showcase2.client.ShowcasePanel;
18:
19: public class ComboBoxStyledSample extends ShowcasePanel {
20:
21: public String getSourceUrl() {
22: return "source/combo/ComboBoxStyledSample.java.html";
23: }
24:
25: public Panel getViewPanel() {
26: if (panel == null) {
27: panel = new Panel();
28:
29: final Store store = new SimpleStore(new String[] { "abbr",
30: "country" }, SampleData.getCountries());
31: store.load();
32:
33: final Template template = new Template(
34: "<div class=\"x-combo-list-item\"><img src=\"images/flags/{abbr}.gif\"> "
35: + "{country}<div class=\"x-clear\"></div></div>");
36:
37: ComboBox cb = new ComboBox();
38: cb.setMinChars(1);
39: cb.setFieldLabel("Countries");
40: cb.setStore(store);
41: cb.setDisplayField("country");
42: cb.setMode(ComboBox.LOCAL);
43: cb.setTriggerAction(ComboBox.ALL);
44: cb.setEmptyText("Select Country");
45: cb.setTypeAhead(true);
46: cb.setSelectOnFocus(true);
47: cb.setWidth(200);
48: cb.setResizable(true);
49: cb.setTpl(template);
50: cb.setTitle("Countries");
51:
52: FormPanel form = new FormPanel();
53: form.setLabelWidth(70);
54: form.setBorder(false);
55: form.add(cb);
56:
57: panel.add(form);
58: }
59: return panel;
60: }
61:
62: public String getIntro() {
63: return "<p>In this sample the entries in the ComboBox dropdown are styled using a simple but "
64: + "powerful templating mechanism and can be customized to meet the users requirements.</p>"
65: + "<p>Also notice that in this example resizing of the dropdown is enabled using a simple ComboBox setting.</p>";
66: }
67: }
|