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.grid;
09:
10: import com.gwtext.client.core.SortDir;
11: import com.gwtext.client.data.*;
12: import com.gwtext.client.widgets.Panel;
13: import com.gwtext.client.widgets.grid.GridPanel;
14: import com.gwtext.client.widgets.grid.GroupingView;
15: import com.gwtext.sample.showcase2.client.SampleData;
16: import com.gwtext.sample.showcase2.client.SampleGrid;
17: import com.gwtext.sample.showcase2.client.ShowcasePanel;
18:
19: public class GridGroupingSample extends ShowcasePanel {
20:
21: public String getSourceUrl() {
22: return "source/grid/GridGroupingSample.java.html";
23: }
24:
25: public Panel getViewPanel() {
26: if (panel == null) {
27: MemoryProxy proxy = new MemoryProxy(SampleData
28: .getCompanyDataLarge());
29: RecordDef recordDef = new RecordDef(new FieldDef[] {
30: new StringFieldDef("company"),
31: new FloatFieldDef("price"),
32: new FloatFieldDef("change"),
33: new FloatFieldDef("pctChange"),
34: new DateFieldDef("lastChanged", "n/j h:ia"),
35: new StringFieldDef("symbol"),
36: new StringFieldDef("industry") });
37:
38: ArrayReader reader = new ArrayReader(recordDef);
39:
40: GroupingStore store = new GroupingStore();
41: store.setReader(reader);
42: store.setDataProxy(proxy);
43: store.setSortInfo(new SortState("company", SortDir.ASC));
44: store.setGroupField("industry");
45: store.load();
46:
47: GroupingView gridView = new GroupingView();
48: gridView.setForceFit(true);
49: gridView
50: .setGroupTextTpl("{text} ({[values.rs.length]} {[values.rs.length > 1 ? \"Items\" : \"Item\"]})");
51:
52: GridPanel grid = new SampleGrid();
53: grid.setStore(store);
54: grid.setView(gridView);
55: grid.setFrame(true);
56: grid.setWidth(620);
57: grid.setHeight(400);
58: grid.setCollapsible(true);
59: grid.setAnimCollapse(false);
60: grid.setTitle("Grouping Example");
61: grid.setIconCls("grid-icon");
62:
63: panel = new Panel();
64: panel.add(grid);
65: }
66: return panel;
67: }
68:
69: public String getIntro() {
70: return "This is an example of a Grouping Grid where data is grouped on a certain data column of the underlying Store. "
71: + "In this example the grouping is done on Industry type.";
72: }
73: }
|