]> git.proxmox.com Git - extjs.git/blame - extjs/classic/classic/test/specs/grid/column/Template.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / test / specs / grid / column / Template.js
CommitLineData
6527f429
DM
1describe("Ext.grid.column.Template", function() {\r
2 \r
3 var grid, store, colRef;\r
4 \r
5 function getCell(rowIdx, colIdx) {\r
6 return grid.getView().getCellInclusive({\r
7 row: rowIdx,\r
8 column: colIdx\r
9 });\r
10 }\r
11 \r
12 function getCellText(rowIdx, colIdx) {\r
13 var cell = getCell(rowIdx, colIdx);\r
14 return Ext.fly(cell).down(grid.getView().innerSelector).dom.innerHTML;\r
15 }\r
16 \r
17 function makeGrid(value) {\r
18 store = new Ext.data.Store({\r
19 model: spec.TestModel,\r
20 data: [{\r
21 field: value\r
22 }]\r
23 });\r
24 \r
25 grid = new Ext.grid.Panel({\r
26 store: store,\r
27 columns: [{\r
28 xtype: 'templatecolumn',\r
29 tpl: 'Hello {field}',\r
30 text: 'Col',\r
31 dataIndex: 'field',\r
32 flex: 1 \r
33 }],\r
34 width: 400,\r
35 height: 100,\r
36 border: false,\r
37 renderTo: Ext.getBody()\r
38 });\r
39 colRef = grid.getColumnManager().getColumns();\r
40 }\r
41 \r
42 beforeEach(function() {\r
43 Ext.define('spec.TestModel', {\r
44 extend: 'Ext.data.Model',\r
45 fields: [{\r
46 name: 'field',\r
47 defaultValue: undefined\r
48 }]\r
49 });\r
50 });\r
51 \r
52 afterEach(function(){\r
53 Ext.destroy(grid, store);\r
54 colRef = store = grid = null;\r
55 Ext.undefine('spec.TestModel');\r
56 Ext.data.Model.schema.clear();\r
57 });\r
58 \r
59 describe("renderer", function() {\r
60 it("should render render when the value is null", function() {\r
61 makeGrid(null);\r
62 expect(getCellText(0, 0)).toBe('Hello ');\r
63 });\r
64 \r
65 it("should render the according to the template", function() {\r
66 makeGrid('Foo');\r
67 expect(getCellText(0, 0)).toBe('Hello Foo');\r
68 });\r
69 });\r
70 \r
71});\r