View Full Version : Disable elements in editors grids

3 Jun 2009, 6:16 AM
Hi everyone, I need your help to solve this little problem. I have an editor grid panel, which is loaded from a data store and I need to do setDisable (false) of a Number Field, according to the value of one of the areas that come in the store. For example, we have a grid with fields quantity, name and available. According to the available value, the field quantity, which is Number Field can be enabled or not, ie if there are products available, the user can change the quantity. The following code is the solution that was implemented, but the problem is that all fields quantity are disabled in the grid function loadtable(idBoton){ var url = _ACTION_LOAD_GRID; var store = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: url }), reader: new Ext.data.JsonReader( { root:'gridProduct' }, [ {name: 'rowIndexGrid', type: 'string', mapping: 'idRow'}, {name: 'quantity', type: 'string', mapping: 'quantity'}, {name: 'name' ,type: 'string', mapping: 'name'}, {name: ' available ',type: 'string', mapping: ' available '}, ] ), remoteSort: true }); store.load(); return store; } var txtCantidadBusqueda = new Ext.form.NumberField({ //new Ext.form.TextField({ id : 'txtQuantitySearch', name:'txtQuantitySearch', style: 'text-align:right; color:blue; ', allowBlank: false, allowNegative: false, decimalSeparator : ',', decimalPrecision : 2, enableKeyEvents : true, listeners:{ keyup : function( extFormTextField, extEventObject ) { bSeRealizaronCambiosCantidadBusqueda = true; actionConfirmar.setDisabled( false ); } } }); var gridSearch = new Ext.grid.EditorGridPanel({ id:'gridSearch', title:'Search Products', iconCls:'icon-grid', height:300, width:930, store: loadTable(),//dataStore, stripeRows: true, clicksToEdit : 1, frame:true, columns:[ {header: " ", width: 20, sortable: true, dataIndex: 'rowIndexGrid', align: 'right', hideable: false, fixed : true }, {header: "quantity", width: 50, sortable: false, dataIndex: 'quantity', //, renderer: showAddButton editor: txtQuantitySearch, enabled: false }, {header: "name", width: 130, sortable: true, dataIndex: 'name'}, {header: "available", width: 10, sortable: true, dataIndex: 'available', hidden:true}, ], sm: new Ext.grid.RowSelectionModel({ singleSelect: true, }), tbar:[ '-', Confirm, '-', Exit, '-' ], listeners : { render : function(r){ disable(); } } }); function disable() { var storeBusq = Ext.getCmp('gridSearch').getStore(); //Ext.data.SimpleStore for (var i = 0; i < storeBusq.getCount(); i++) { var record = storeBusq.getAt(i); //Ext.data.Record if ( record.get("available") == 'F' ) { Ext.getCmp('txtQuantitySearch').setDisabled(true); } } } Please, I need all the help provided, I already have 2 days trying to solve this.

3 Jun 2009, 6:29 AM

3 Jun 2009, 6:31 AM
look at the API's beforeedit event for the editor grid panel.

3 Jun 2009, 7:18 AM
1) Do not post the same question in multiple places.

2) http://extjs.com/learn/Ext_Forum_Help and http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly