]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This example shows how to use a Grid with a back end Store via Ext Direct proxy.\r | |
3 | *\r | |
4 | * The grid will be populated with the data queried from a virtual "table" hardcoded\r | |
5 | * in the PHP script that handles the requests; sorting is also performed remotely.\r | |
6 | */\r | |
7 | Ext.define('KitchenSink.view.direct.Grid', {\r | |
8 | extend: 'Ext.grid.Panel',\r | |
9 | xtype: 'direct-grid',\r | |
10 | controller: 'directgrid',\r | |
11 | \r | |
12 | requires: [\r | |
13 | 'KitchenSink.view.direct.GridController'\r | |
14 | ],\r | |
15 | \r | |
16 | //<example>\r | |
17 | exampleTitle: 'Grid with Ext Direct back end',\r | |
18 | exampleDescription: [\r | |
19 | '<p>This example shows how to connect a Grid to the remote server via a Direct proxy.</p>',\r | |
20 | '<p>The data is queried from a virtual "table"; there are two datasets hardcoded',\r | |
21 | 'in the example PHP script that handles the requests. Data sorting is also remote</p>'\r | |
22 | ].join(''),\r | |
23 | \r | |
24 | otherContent: [{\r | |
25 | type: 'ViewController',\r | |
26 | path: 'classic/samples/view/direct/GridController.js'\r | |
27 | }, {\r | |
28 | type: 'Base ViewController',\r | |
29 | path: 'classic/samples/view/direct/DirectVC.js'\r | |
30 | }, {\r | |
31 | type: 'Server TestAction class',\r | |
32 | path: 'data/direct/source.php?file=testaction'\r | |
33 | }, {\r | |
34 | type: 'Server API configuration',\r | |
35 | path: 'data/direct/source.php?file=config'\r | |
36 | }],\r | |
37 | //</example>\r | |
38 | \r | |
39 | title: 'Company Grid',\r | |
40 | width: 600,\r | |
41 | height: 350,\r | |
42 | \r | |
43 | store: {\r | |
44 | fields: ['name', 'revenue'],\r | |
45 | remoteSort: true,\r | |
46 | sorters: [{\r | |
47 | property: 'name',\r | |
48 | direction: 'ASC'\r | |
49 | }],\r | |
50 | proxy: {\r | |
51 | type: 'direct',\r | |
52 | directFn: 'TestAction.getGrid',\r | |
53 | metadata: {\r | |
54 | table: 'customers'\r | |
55 | }\r | |
56 | }\r | |
57 | },\r | |
58 | \r | |
59 | columns: [{\r | |
60 | dataIndex: 'name',\r | |
61 | flex: 1,\r | |
62 | text: 'Name'\r | |
63 | }, {\r | |
64 | dataIndex: 'revenue',\r | |
65 | align: 'right',\r | |
66 | width: 140,\r | |
67 | text: 'Annual revenue',\r | |
68 | renderer: Ext.util.Format.usMoney\r | |
69 | }],\r | |
70 | \r | |
71 | header: {\r | |
72 | items: [{\r | |
73 | xtype: 'combobox',\r | |
74 | fieldLabel: 'Choose table',\r | |
75 | queryMode: 'local',\r | |
76 | displayField: 'desc',\r | |
77 | valueField: 'table',\r | |
78 | forceSelection: true,\r | |
79 | editable: false,\r | |
80 | value: 'customers',\r | |
81 | store: {\r | |
82 | fields: ['table', 'desc'],\r | |
83 | data: [\r | |
84 | { table: 'customers', desc: 'Existing customers' },\r | |
85 | { table: 'leads', desc: 'Sales leads' }\r | |
86 | ]\r | |
87 | },\r | |
88 | listeners: {\r | |
89 | change: 'onTableChange'\r | |
90 | }\r | |
91 | }]\r | |
92 | }\r | |
93 | });\r |