]> git.proxmox.com Git - extjs.git/blob - extjs/examples/kitchensink/classic/samples/view/grid/SpreadsheetController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / kitchensink / classic / samples / view / grid / SpreadsheetController.js
1 /**
2 * Controls the Spreadsheet example view.
3 */
4 Ext.define('KitchenSink.view.grid.SpreadsheetController', {
5 extend: 'Ext.app.ViewController',
6
7 alias: 'controller.spreadsheet',
8
9 formatDays: function (value) {
10 return (value === 1) ? '1 day' : (value + ' days');
11 },
12
13 getSelectionModel: function () {
14 var grid = this.getView();
15 return grid.getSelectionModel();
16 },
17
18 onRefresh: function () {
19 var grid = this.getView();
20 grid.store.reload();
21 },
22
23 onSelectionChange: function (grid, selection) {
24 var status = this.lookupReference('status'),
25 message = '??',
26 firstRowIndex,
27 firstColumnIndex,
28 lastRowIndex,
29 lastColumnIndex;
30
31 if (!selection) {
32 message = 'No selection';
33 }
34 else if (selection.isCells) {
35 firstRowIndex = selection.getFirstRowIndex();
36 firstColumnIndex = selection.getFirstColumnIndex();
37 lastRowIndex = selection.getLastRowIndex();
38 lastColumnIndex = selection.getLastColumnIndex();
39
40 message = 'Selected cells: ' + (lastColumnIndex - firstColumnIndex + 1) + 'x' + (lastRowIndex - firstRowIndex + 1) +
41 ' at (' + firstColumnIndex + ',' + firstRowIndex + ')';
42 }
43 else if (selection.isRows) {
44 message = 'Selected rows: ' + selection.getCount();
45 }
46 else if (selection.isColumns) {
47 message = 'Selected columns: ' + selection.getCount();
48 }
49
50 status.update(message);
51 },
52
53 toggleRowSelect: function(button, pressed) {
54 var sel = this.getSelectionModel();
55 sel.setRowSelect(pressed);
56 },
57
58 toggleCellSelect: function(button, pressed) {
59 var sel = this.getSelectionModel();
60 sel.setCellSelect(pressed);
61 },
62
63 toggleColumnSelect: function(button, pressed) {
64 var sel = this.getSelectionModel();
65 sel.setColumnSelect(pressed);
66 }
67 });