comparison app/view/grid/PKommentar.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 9ab7b1eed9f8
children fab0b7be5aca
comparison
equal deleted inserted replaced
822:a0666d755405 823:5ed0e6273888
24 viewConfig: { 24 viewConfig: {
25 deferEmptyText: false 25 deferEmptyText: false
26 }, 26 },
27 27
28 recordId: null, 28 recordId: null,
29 readOnly: true,
30 allowDeselect: true,
29 31
30 initComponent: function() { 32 initComponent: function() {
31 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { 33 this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
32 clicksToMoveEditor: 1, 34 clicksToMoveEditor: 1,
33 autoCancel: false, 35 autoCancel: false,
101 editor: { 103 editor: {
102 xtype: 'textarea', 104 xtype: 'textarea',
103 allowBlank: false 105 allowBlank: false
104 } 106 }
105 }]; 107 }];
108 this.listeners = {
109 select: {
110 fn: this.activateRemoveButton,
111 scope: this
112 },
113 deselect: {
114 fn: this.deactivateRemoveButton,
115 scope: this
116 }
117 };
106 this.initData(); 118 this.initData();
107 this.callParent(arguments); 119 this.callParent(arguments);
120 this.setReadOnly(true); //Grid is always initialised as RO
108 }, 121 },
109 122
110 initData: function() { 123 initData: function() {
111 this.store = Ext.create('Lada.store.PKommentare'); 124 this.store = Ext.create('Lada.store.PKommentare');
112 this.store.load({ 125 this.store.load({
130 this.getPlugin('rowedit').enable(); 143 this.getPlugin('rowedit').enable();
131 } 144 }
132 this.down('button[action=delete]').enable(); 145 this.down('button[action=delete]').enable();
133 this.down('button[action=add]').enable(); 146 this.down('button[action=add]').enable();
134 } 147 }
148 },
149 /**
150 * Activate the Remove Button
151 */
152 activateRemoveButton: function(selection, record) {
153 var grid = this;
154 //only enable the remove buttone, when the grid is editable.
155 if (! grid.readOnly) {
156 grid.down('button[action=delete]').enable();
157 }
158 },
159 /**
160 * Activate the Remove Button
161 */
162 deactivateRemoveButton: function(selection, record) {
163 var grid = this;
164 //only enable the remove buttone, when the grid is editable.
165 if (! grid.readOnly) {
166 grid.down('button[action=delete]').disable();
167 }
135 } 168 }
169
136 }); 170 });

http://lada.wald.intevation.org