PDA

View Full Version : problem with store in component



tokkaido
27 Aug 2009, 7:29 AM
Hi, someone can help me with this problem?

I'm trying to build a component to load it from another page. so far so good. but I have a problem with the function that load the combo. If I use normal (I mean not from the component) It's work fine, but, from the component doesn't.

Where I put the function (getDataStore) that loads the store?

this is my code



Ext.ux.formNuevaObra = Ext.extend(Ext.Panel, {

initComponent:function(){

/*los campos para el formulario*/
constructorasStore = this.getDataStore();

constructorasStore.load();

var constructoraCombo = new Ext.form.ComboBox({
store: constructorasStore,
name:'constructora',
id:'constructora',
valueField : 'id',
displayField:'nombre',
triggerAction: 'all',
mode: 'local',
emptyText:"Seleccione una constructora",
fieldLabel:'Constructora',
width: 200
});

var numeroObra = new Ext.form.NumberField({
fieldLabel:'Nš Obra',
name:'numeroObra',
id:'numeroObra'
});

var nombreObra = new Ext.form.TextField({
fieldLabel:'Nombre de Obra',
name:'nombreObra',
id:'nombreObra'
});

var mandanteObra = new Ext.form.TextField({
fieldLabel:'Mandante',
name:'MandanteObra',
id:'MandanteObra'
});

var ubicacionObra = new Ext.form.TextField({
fieldLabel:'Ubicacion',
name:'UbicacionObra',
id:'UbicacionObra',
autoCreate: {tag: 'input', type: 'text', size: '50', autocomplete: 'off', maxlength: '50'}
});

var finicioObra = new Ext.form.DateField({
fieldLabel:'Fecha Inicio',
name:'finicioObra',
id:'finicioObra'
});

var fterminoObra = new Ext.form.DateField({
fieldLabel:'Fecha Termino',
name:'fterminoObra',
id:'fterminoObra'
});

var duracionObra = new Ext.form.TextField({
fieldLabel:'Duracion',
name:'duracionObra',
id:'duracionObra'
});

var montoObra = new Ext.form.NumberField({
fieldLabel:'Monto',
name:'montoObra',
id:'montoObra',
autoCreate: {tag: 'input', type: 'text', size: '10', autocomplete: 'off', maxlength: '10'}
});

/*formulario de datos*/
var formulario = new Ext.FormPanel({
border: false,
bodyStyle:'padding: 10px',
items:[
numeroObra,
constructoraCombo,
nombreObra,
mandanteObra,
ubicacionObra,
finicioObra,
fterminoObra,
duracionObra,
montoObra
]
});

// apply config
Ext.apply(this,{
title:'Datos de Nueva Obra',
items:[

formulario

]

});

Ext.ux.formNuevaObra.superclass.initComponent.call(this);

getDataStore: function(){
var store = new Ext.data.JsonStore({
url:'constructoras.php',
root:'data',
fields: ['id','nombre']
});
return store;
}
} // eo function initComponent
});

Ext.reg('formNuevaObra', Ext.ux.formNuevaObra);


any enlightenment will be appreciated by me :D