Mercurial > lada > lada-client
comparison app/controller/grid/MessprogrammeList.js @ 977:56470a075e6e stammdatengrids
Added methods to the controllers to disable/enable buttons in the toolbar when rows are (de)selected
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 03 Dec 2015 09:26:43 +0100 |
parents | fb99332bb48e |
children |
comparison
equal
deleted
inserted
replaced
976:3c770fc7cf19 | 977:56470a075e6e |
---|---|
20 * Initialize the Controller with listeners | 20 * Initialize the Controller with listeners |
21 */ | 21 */ |
22 init: function() { | 22 init: function() { |
23 this.control({ | 23 this.control({ |
24 'messprogrammelistgrid': { | 24 'messprogrammelistgrid': { |
25 itemdblclick: this.editItem | 25 itemdblclick: this.editItem, |
26 select: this.activateButtons, | |
27 deselect: this.deactivateButtons | |
26 }, | 28 }, |
27 'messprogrammelistgrid toolbar button[action=addMessprogramm]': { | 29 'messprogrammelistgrid toolbar button[action=addMessprogramm]': { |
28 click: this.addMessprogrammItem | 30 click: this.addMessprogrammItem |
29 }, | 31 }, |
30 'messprogrammelistgrid toolbar button[action=genProbenFromMessprogramm]': { | 32 'messprogrammelistgrid toolbar button[action=genProbenFromMessprogramm]': { |
101 scope: this | 103 scope: this |
102 }); | 104 }); |
103 } | 105 } |
104 }, | 106 }, |
105 | 107 |
108 /** | |
109 * Toggles the buttons in the toolbar | |
110 **/ | |
111 activateButtons: function(rowModel, record) { | |
112 var grid = rowModel.view.up('grid'); | |
113 this.buttonToggle(true, grid); | |
114 }, | |
115 | |
116 /** | |
117 * Toggles the buttons in the toolbar | |
118 **/ | |
119 deactivateButtons: function(rowModel, record) { | |
120 var grid = rowModel.view.up('grid'); | |
121 // Only disable buttons when nothing is selected | |
122 if (rowModel.selected.items == 0) { | |
123 this.buttonToggle(false, grid); | |
124 } | |
125 }, | |
126 | |
127 /** | |
128 * Enables/Disables a set of buttons | |
129 **/ | |
130 buttonToggle: function(enabled, grid) { | |
131 if (!enabled) { | |
132 grid.down('button[action=genProbenFromMessprogramm]').disable(); | |
133 } | |
134 else { | |
135 grid.down('button[action=genProbenFromMessprogramm]').enable(); | |
136 } | |
137 }, | |
138 | |
106 reload: function(btn) { | 139 reload: function(btn) { |
107 if (btn === 'yes') { | 140 if (btn === 'yes') { |
108 location.reload(); | 141 location.reload(); |
109 } | 142 } |
110 } | 143 } |