comparison app/view/grid/Probenzusatzwert.js @ 823:5ed0e6273888

Only enable delete button in grids when an entry was selected
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 14:03:18 +0200
parents 52c50a5f457b
children fab0b7be5aca
comparison
equal deleted inserted replaced
822:a0666d755405 823:5ed0e6273888
23 deferEmptyText: false 23 deferEmptyText: false
24 }, 24 },
25 margin: '0, 5, 5, 5', 25 margin: '0, 5, 5, 5',
26 26
27 recordId: null, 27 recordId: null,
28 readOnly: true,
29 allowDeselect: true,
28 30
29 initComponent: function() { 31 initComponent: function() {
30 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { 32 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
31 clicksToMoveEditor: 1, 33 clicksToMoveEditor: 1,
32 autoCancel: false, 34 autoCancel: false,
148 enforceMaxLength: true, 150 enforceMaxLength: true,
149 allowExponential: false, 151 allowExponential: false,
150 allowDecimal: false 152 allowDecimal: false
151 } 153 }
152 }]; 154 }];
155 this.listeners = {
156 select: {
157 fn: this.activateRemoveButton,
158 scope: this
159 },
160 deselect: {
161 fn: this.deactivateRemoveButton,
162 scope: this
163 }
164 };
153 this.initData(); 165 this.initData();
154 this.callParent(arguments); 166 this.callParent(arguments);
167 this.setReadOnly(true); //Grid is always initialised as RO
155 }, 168 },
156 169
157 initData: function() { 170 initData: function() {
158 this.store = Ext.create('Lada.store.Zusatzwerte'); 171 this.store = Ext.create('Lada.store.Zusatzwerte');
159 this.store.load({ 172 this.store.load({
177 this.getPlugin('rowedit').enable(); 190 this.getPlugin('rowedit').enable();
178 } 191 }
179 this.down('button[action=delete]').enable(); 192 this.down('button[action=delete]').enable();
180 this.down('button[action=add]').enable(); 193 this.down('button[action=add]').enable();
181 } 194 }
195 },
196 /**
197 * Activate the Remove Button
198 */
199 activateRemoveButton: function(selection, record) {
200 var grid = this;
201 //only enable the remove buttone, when the grid is editable.
202 if (! grid.readOnly) {
203 grid.down('button[action=delete]').enable();
204 }
205 },
206 /**
207 * Activate the Remove Button
208 */
209 deactivateRemoveButton: function(selection, record) {
210 var grid = this;
211 //only enable the remove buttone, when the grid is editable.
212 if (! grid.readOnly) {
213 grid.down('button[action=delete]').disable();
214 }
182 } 215 }
216
183 }); 217 });

http://lada.wald.intevation.org