PDA

View Full Version : JsonStore load event



janixams
21 Jun 2008, 5:14 AM
Hi all,
I have a JsonStore and I need to populate a field in my form when this store has been loaded. The problem is: My store never take data.
Here is the code...

JS code:


form_edit_proyecto = new Ext.form.Form({labelAlign: 'top', url:'./PHP/procesar.php?editProyecto'});

var edit_nombres_proy = new Ext.data.JsonStore({
fields: ['nombre'],
root: 'nombre_proyecto',
url: './PHP/datos_generador.php?obtener_proy'
});

edit_nombres_proy.on('load',function(){
form_edit_proyecto.findField('nombre_proyecto_L').setValue(edit_nombres_proy.getAt(0).data.nombre);
});
form_edit_proyecto.column({width:225},
new Ext.form.TextField({
fieldLabel: 'Nombre actual del Proyecto',
name: 'nombre_proyecto_L',
width:200,
disabled:true
})
);

edit_nombres_proy.load();



Json Response:

{success:true,"nombre_proyecto":{"nombre":"DayProy"}}

Thanks in advance.

mjlecomte
21 Jun 2008, 9:28 AM
I don't understand what you are asking, but have you looked here:
http://examples.extjs.eu/?ex=formloadsubmit

janixams
21 Jun 2008, 11:46 AM
Thanks for replay. I saw the example but It was a server side error.
Though, all is not happiness because I don't now what I am doing wrong: in the same grid, the PagingToolbar doesn't shows.
I don't know that to do now.

I give some code here:
[php]
var grid_plantilla = new Ext.grid.Grid('grid_plantilla_contenido', {
ds: ds_grid_plantilla,
cm: grid_plantilla_ColModel,
autoExpandColumn: 'nombre',
enableColLock: false,
selModel: tipo_selection
});

var layout_plantilla = Ext.BorderLayout.create({
center: {
margins:{left:3,top:3,right:3,bottom:3},
panels: [new Ext.GridPanel(grid_plantilla)]
}
}, 'grid_plantilla_panel');

grid_plantilla.render();

var grid_plantilla_Footer = grid_plantilla.getView().getFooterPanel(true);

var paging_plantilla = new Ext.PagingToolbar(grid_plantilla_Footer, ds_grid_plantilla, {
pageSize: 10,
displayInfo: true,
beforePageText :'P

mjlecomte
21 Jun 2008, 1:27 PM
Well, I haven't used Ext1 in some time, not sure if it's different but in Ext 2 you would typically use:
http://extjs.com/deploy/dev/docs/?class=Ext.grid.GridPanel&member=bbar or
http://extjs.com/deploy/dev/docs/?class=Ext.grid.GridPanel&member=tbar to bind the paging toolbar to the grid panel. I see where you've instanciated, but I don't think you've attached or rendered it to anything.

mjlecomte
21 Jun 2008, 1:28 PM
I'm quite confused though, didn't the code you posted before use form load etc. Now you're talking about a grid?