PDA

View Full Version : EditorGridPanel Editor Issues



jaadolio
18 Jan 2011, 8:51 AM
I hope someone can help me out with this.

I created 2 EditorGridPanel instances from a base class that I wrote using Ext.Extend.

Both grid instances shared the same colModel, store, etc., however I have noticed that when I clicked on a cell of one grid to activate the Editor's textfield, it works perfectly, but if i go to the other grid and click on the same cell, the Editor's textfield is not working and viceversa.

I checked the base class but I don't see any problems with it. Here I include the code:



Matriz.gAcademicos = Ext.extend(Ext.grid.EditorGridPanel, {

initComponent: function() {

this.alm_gAcad = new Ext.data.ArrayStore({fields: campos_gAcad});

this.cmpl_gAcad = new Ext.ux.grid.ColumnHeaderGroup({rows: [encab_PMAcad]});

this.col_gAcad = new Ext.grid.ColumnModel(encab_SMAcad);

var config = {
frame: true
,store: this.alm_gAcad
,sm: new Ext.grid.CheckboxSelectionModel()
,plugins: this.cmpl_gAcad
,colModel: this.col_gAcad
,clicksToEdit: 1
,width: 858
,height: 250
}; // Fin de la Configuración

Ext.apply(this, Ext.apply(this.initialConfig, config));

Matriz.gAcademicos.superclass.initComponent.apply(this, arguments);
} // End initComponent

}); //End Ext.extend(Ext.grid.EditorGridPanel,

Any help with this will be appreciated.

Thanks

18 Jan 2011, 12:28 PM
seems like encab_SMAcad is a global reference

jaadolio
18 Jan 2011, 12:51 PM
Yes, "encab_SMAcad" is a global variable that receives all the fields definition from a php code since the information is retrieved from a MySQL database.

This is the code:



$campos = "{name: 'id_carrera', type: 'int'},
{name: 'carrera'},
{name: 'acum_AS', type: 'int'},
{name: 'acum_F', type: 'int'},";

$encab_princ = "{header: 'Carrera', colspan: 1, sortable: true, align: 'center'},
{header: 'Acumulado.<br />Estud.', colspan: 2, sortable: true, align: 'center'},";

$encab_secund = "{header: 'Nombre', width: 210, sortable: true, dataIndex: 'carrera', align: 'center'},
{header: 'Acum.<br />Ambos<br />Sexos', width: 50, sortable: true, align: 'center',
dataIndex: 'acum_AS',
css:'background-color: #76923C; border: thin 1px #76923C; font-weight:bolder;'},

{header: 'Acum.<br />Fem.', width: 50, sortable: true, align: 'center', dataIndex: 'acum_F',
css:'background-color: #F2DBDB; border: thin 1px #F2DBDB; font-weight:bolder;'},";

//We go through an array of values retrieved from the database and assign the specific values to the strings...
foreach($grados_academicos as $grado){
$campos .= "{name: '".$grado['c_grado']."_AS', type: 'int'},
{name: '".$grado['c_grado']."_F', type: 'int'},";

$encab_princ .= "{header: '".$grado['abr_grado']."', colspan: 2, sortable: true, align: 'center'},";

$encab_secund .= "{header:'Ambos<br />Sexos', width: 50, sortable: true,
align: 'center', dataIndex: '".$grado['c_grado']."_AS',
editor: new Ext.form.NumberField({allowBlank:false, allowNegative:false, maxValue: 10000})},

{header:'Fem.', width: 50, sortable: true,
align: 'center', dataIndex: '".$grado['c_grado']."_F',
editor: new Ext.form.NumberField({allowBlank:false, allowNegative:false, maxValue: 10000})},";

}//foreach($grados_academicos as $grado)
$campos = substr($campos, 0, strlen($campos)-1);
$encab_princ = substr($encab_princ, 0, strlen($encab_princ)-1);
$encab_secund = substr($encab_secund, 0, strlen($encab_secund)-1);


//Here I assign the values from the php strings to the global javascript variables
echo "campos_gAcad = [".$campos."];";
echo "encab_PMAcad = [".$encab_princ."];";
echo "encab_SMAcad = [".$encab_secund."];";

Since both grids need to have the same structure from the base class I posted before, what will be a good solution to allow both grid instances being editable without any inconvenients?