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.*;
11: import com.gwtext.client.widgets.Panel;
12: import com.gwtext.client.widgets.form.ComboBox;
13: import com.gwtext.client.widgets.form.FormPanel;
14: import com.gwtext.sample.showcase2.client.SampleData;
15: import com.gwtext.sample.showcase2.client.ShowcasePanel;
16: import com.gwtextux.client.data.PagingMemoryProxy;
17:
18: /**
19: * ComboBox with paging dropdown.
20: */
21: public class ComboBoxPagingSample extends ShowcasePanel {
22:
23: public String getSourceUrl() {
24: return "source/combo/ComboBoxPagingSample.java.html";
25: }
26:
27: public Panel getViewPanel() {
28: if (panel == null) {
29: panel = new Panel();
30:
31: MemoryProxy proxy = new PagingMemoryProxy(SampleData
32: .getCompanyDataLarge());
33: RecordDef recordDef = new RecordDef(new FieldDef[] {
34: new StringFieldDef("company"),
35: new FloatFieldDef("price"),
36: new FloatFieldDef("change"),
37: new FloatFieldDef("pctChange"),
38: new DateFieldDef("lastChanged", "n/j h:ia") });
39:
40: ArrayReader reader = new ArrayReader(recordDef);
41: final Store store = new Store(proxy, reader);
42: store.load();
43:
44: ComboBox cb = new ComboBox();
45: cb.setMinChars(1);
46: cb.setFieldLabel("Company");
47: cb.setStore(store);
48: cb.setDisplayField("company");
49: cb.setMode(ComboBox.REMOTE);
50: cb.setTriggerAction(ComboBox.ALL);
51: cb.setEmptyText("Enter company");
52: cb.setLoadingText("Searching...");
53: cb.setTypeAhead(true);
54: cb.setSelectOnFocus(true);
55: cb.setWidth(250);
56: cb.setPageSize(10);
57:
58: FormPanel form = new FormPanel();
59: form.setLabelWidth(70);
60: form.setBorder(false);
61: form.add(cb);
62:
63: panel.add(form);
64: }
65: return panel;
66: }
67:
68: public String getIntro() {
69: return "<p>In this sample the entries in ComboBox dropdown provide paging capabilities. The page size and display of the entries are fully customizable.</p>"
70: + "<p>Data for the CombBox is loaded from a Store which can be populated using local or remote data.</p>";
71: }
72: }
|