]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | describe('Ext.grid.column.RowNumberer', function () {\r |
2 | var panel, store,\r | |
3 | synchronousLoad = true,\r | |
4 | proxyStoreLoad = Ext.data.ProxyStore.prototype.load,\r | |
5 | loadStore;\r | |
6 | \r | |
7 | function createGrid(gridCfg, storeCfg) {\r | |
8 | store = new Ext.data.Store(Ext.apply({\r | |
9 | fields: ['name', 'email', 'phone'],\r | |
10 | data: [\r | |
11 | { 'name': 'Lisa', 'email':'lisa@simpsons.com', 'phone':'555-111-1224' },\r | |
12 | { 'name': 'Bart', 'email':'bart@simpsons.com', 'phone':'555-222-1234' },\r | |
13 | { 'name': 'Homer', 'email':'homer@simpsons.com', 'phone':'555-222-1244' },\r | |
14 | { 'name': 'Marge', 'email':'marge@simpsons.com', 'phone':'555-222-1254' }\r | |
15 | ],\r | |
16 | autoDestroy: true\r | |
17 | }, storeCfg));\r | |
18 | \r | |
19 | panel = new Ext.grid.Panel(Ext.apply({\r | |
20 | store: store,\r | |
21 | columns: [\r | |
22 | { xtype: 'rownumberer'},\r | |
23 | { header: 'Name', dataIndex: 'name', width: 100 },\r | |
24 | { header: 'Email', dataIndex: 'email', width: 100 },\r | |
25 | { header: 'Phone', dataIndex: 'phone', width: 100 }\r | |
26 | ],\r | |
27 | height: 200,\r | |
28 | width: 400\r | |
29 | }, gridCfg));\r | |
30 | }\r | |
31 | \r | |
32 | function createTree(treeCfg, storeCfg) {\r | |
33 | store = new Ext.data.TreeStore(Ext.apply({\r | |
34 | root: {\r | |
35 | expanded: true,\r | |
36 | children: [{\r | |
37 | text: 'detention',\r | |
38 | leaf: true\r | |
39 | }, {\r | |
40 | text: 'homework',\r | |
41 | expanded: true,\r | |
42 | children: [{\r | |
43 | text: 'book report',\r | |
44 | leaf: true\r | |
45 | }, {\r | |
46 | text: 'algebra',\r | |
47 | leaf: true\r | |
48 | }]\r | |
49 | }, {\r | |
50 | text: 'buy lottery tickets',\r | |
51 | leaf: true\r | |
52 | }]\r | |
53 | }\r | |
54 | }, storeCfg));\r | |
55 | \r | |
56 | panel = new Ext.tree.Panel(Ext.apply({\r | |
57 | width: 200,\r | |
58 | height: 150,\r | |
59 | store: store,\r | |
60 | rootVisible: false,\r | |
61 | hideHeaders: true,\r | |
62 | columns: [{\r | |
63 | xtype: 'rownumberer'\r | |
64 | }, {\r | |
65 | text: 'Data',\r | |
66 | dataIndex: 'text',\r | |
67 | flex: 1\r | |
68 | }]\r | |
69 | }, treeCfg));\r | |
70 | }\r | |
71 | \r | |
72 | beforeEach(function() {\r | |
73 | // Override so that we can control asynchronous loading\r | |
74 | loadStore = Ext.data.ProxyStore.prototype.load = function() {\r | |
75 | proxyStoreLoad.apply(this, arguments);\r | |
76 | if (synchronousLoad) {\r | |
77 | this.flushLoad.apply(this, arguments);\r | |
78 | }\r | |
79 | return this;\r | |
80 | };\r | |
81 | });\r | |
82 | \r | |
83 | afterEach(function() {\r | |
84 | // Undo the overrides.\r | |
85 | Ext.data.ProxyStore.prototype.load = proxyStoreLoad;\r | |
86 | \r | |
87 | Ext.destroy(panel);\r | |
88 | panel = store = null;\r | |
89 | });\r | |
90 | \r | |
91 | describe('grids', function () {\r | |
92 | it('should create numbered rows', function () {\r | |
93 | var view;\r | |
94 | \r | |
95 | createGrid({\r | |
96 | renderTo: Ext.getBody()\r | |
97 | });\r | |
98 | \r | |
99 | view = panel.view;\r | |
100 | \r | |
101 | expect(Ext.fly(view.getNode(0)).down('td', true)).toHaveCls('x-grid-cell-row-numberer');\r | |
102 | expect(Ext.fly(view.getNode(0)).down('.x-grid-cell-inner', true).innerHTML).toBe('1');\r | |
103 | expect(Ext.fly(view.getNode(1)).down('.x-grid-cell-inner', true).innerHTML).toBe('2');\r | |
104 | });\r | |
105 | \r | |
106 | describe('beforeRender method', function () {\r | |
107 | it('should lookup up the rowbody feature by tablepanel', function () {\r | |
108 | // See EXTJSIV-11504.\r | |
109 | createGrid();\r | |
110 | \r | |
111 | expect(function () {\r | |
112 | panel.columns[0].beforeRender();\r | |
113 | }).not.toThrow();\r | |
114 | });\r | |
115 | });\r | |
116 | \r | |
117 | it("should be able to survive a full row update", function() {\r | |
118 | createGrid();\r | |
119 | var rec = store.first();\r | |
120 | rec.set('name', 'Foo');\r | |
121 | expect(function() {\r | |
122 | rec.commit();\r | |
123 | }).not.toThrow();\r | |
124 | });\r | |
125 | });\r | |
126 | \r | |
127 | describe('trees', function () {\r | |
128 | it('should create numbered rows', function () {\r | |
129 | var view;\r | |
130 | \r | |
131 | createTree({\r | |
132 | renderTo: Ext.getBody()\r | |
133 | });\r | |
134 | \r | |
135 | view = panel.view;\r | |
136 | \r | |
137 | expect(Ext.fly(view.getNode(0)).down('td', true)).toHaveCls('x-grid-cell-row-numberer');\r | |
138 | expect(Ext.fly(view.getNode(0)).down('.x-grid-cell-inner', true).innerHTML).toBe('1');\r | |
139 | expect(Ext.fly(view.getNode(1)).down('.x-grid-cell-inner', true).innerHTML).toBe('2');\r | |
140 | });\r | |
141 | \r | |
142 | describe('beforeRender method', function () {\r | |
143 | it('should lookup up the rowbody feature by tablepanel', function () {\r | |
144 | // See EXTJSIV-11504.\r | |
145 | createTree();\r | |
146 | \r | |
147 | expect(function () {\r | |
148 | panel.columns[0].beforeRender();\r | |
149 | }).not.toThrow();\r | |
150 | });\r | |
151 | });\r | |
152 | });\r | |
153 | });\r |