Mercurial > lada > lada-client
comparison app/controller/grid/ProbeList.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 | f73ca04d73a7 |
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 'probelistgrid': { | 24 'probelistgrid': { |
25 itemdblclick: this.editItem | 25 itemdblclick: this.editItem, |
26 select: this.activateButtons, | |
27 deselect: this.deactivateButtons | |
26 }, | 28 }, |
27 'probelistgrid toolbar button[action=addProbe]': { | 29 'probelistgrid toolbar button[action=addProbe]': { |
28 click: this.addProbeItem | 30 click: this.addProbeItem |
29 }, | 31 }, |
30 'probelistgrid toolbar button[action=import]': { | 32 'probelistgrid toolbar button[action=import]': { |
297 } | 299 } |
298 } | 300 } |
299 }); | 301 }); |
300 }, | 302 }, |
301 | 303 |
304 /** | |
305 * Toggles the buttons in the toolbar | |
306 **/ | |
307 activateButtons: function(rowModel, record) { | |
308 var grid = rowModel.view.up('grid'); | |
309 this.buttonToggle(true, grid); | |
310 }, | |
311 | |
312 /** | |
313 * Toggles the buttons in the toolbar | |
314 **/ | |
315 deactivateButtons: function(rowModel, record) { | |
316 var grid = rowModel.view.up('grid'); | |
317 // Only disable buttons when nothing is selected | |
318 if (rowModel.selected.items == 0) { | |
319 this.buttonToggle(false, grid); | |
320 } | |
321 }, | |
322 | |
323 /** | |
324 * Enables/Disables a set of buttons | |
325 **/ | |
326 buttonToggle: function(enabled, grid) { | |
327 if (!enabled) { | |
328 grid.down('button[action=export]').disable(); | |
329 grid.down('button[action=print]').disable(); | |
330 } | |
331 else { | |
332 grid.down('button[action=export]').enable(); | |
333 grid.down('button[action=print]').enable(); | |
334 } | |
335 }, | |
336 | |
302 reload: function(btn) { | 337 reload: function(btn) { |
303 if (btn === 'yes') { | 338 if (btn === 'yes') { |
304 location.reload(); | 339 location.reload(); |
305 } | 340 } |
306 } | 341 } |