]>
git.proxmox.com Git - extjs.git/blob - extjs/examples/kitchensink/classic/samples/view/grid/SpreadsheetController.js
2 * Controls the Spreadsheet example view.
4 Ext
.define('KitchenSink.view.grid.SpreadsheetController', {
5 extend
: 'Ext.app.ViewController',
7 alias
: 'controller.spreadsheet',
9 formatDays: function (value
) {
10 return (value
=== 1) ? '1 day' : (value
+ ' days');
13 getSelectionModel: function () {
14 var grid
= this.getView();
15 return grid
.getSelectionModel();
18 onRefresh: function () {
19 var grid
= this.getView();
23 onSelectionChange: function (grid
, selection
) {
24 var status
= this.lookupReference('status'),
32 message
= 'No selection';
34 else if (selection
.isCells
) {
35 firstRowIndex
= selection
.getFirstRowIndex();
36 firstColumnIndex
= selection
.getFirstColumnIndex();
37 lastRowIndex
= selection
.getLastRowIndex();
38 lastColumnIndex
= selection
.getLastColumnIndex();
40 message
= 'Selected cells: ' + (lastColumnIndex
- firstColumnIndex
+ 1) + 'x' + (lastRowIndex
- firstRowIndex
+ 1) +
41 ' at (' + firstColumnIndex
+ ',' + firstRowIndex
+ ')';
43 else if (selection
.isRows
) {
44 message
= 'Selected rows: ' + selection
.getCount();
46 else if (selection
.isColumns
) {
47 message
= 'Selected columns: ' + selection
.getCount();
50 status
.update(message
);
53 toggleRowSelect: function(button
, pressed
) {
54 var sel
= this.getSelectionModel();
55 sel
.setRowSelect(pressed
);
58 toggleCellSelect: function(button
, pressed
) {
59 var sel
= this.getSelectionModel();
60 sel
.setCellSelect(pressed
);
63 toggleColumnSelect: function(button
, pressed
) {
64 var sel
= this.getSelectionModel();
65 sel
.setColumnSelect(pressed
);