PDA

View Full Version : Ext.data.Store does not reload inmediately



christian130
22 Jul 2010, 7:21 AM
when trying to populate A ENTIRE GRID using the ajax from a combobox in the select listener when i try to recall or reload the datastore i'm still getting the old values, instead of the new ones. i have to get the new values because according to the parameter selected in the combobox the textfields and the others editor will populate with that json data read from server using ajax, accoding with another combobox that fetch remote data


PLEASE CLICK IN THE LINK BELOW TO SEE SOURCE CODE HIGHLIGHTED



var cm = new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [{
id: 'ci',
header: 'Periodo Declarado',
dataIndex: 'ci',
width: 150,
editor: new fm.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform: 'PerDecl',
lazyRender: true,
listClass: 'x-combo-list-small',
mode:'local',
listeners:{
expand: function (combo){
//alert("asd");
},
collapse: function(combo,record,number){
},
select:function(v, params, record){
ds_random_employee_data_active.remove();
var varAnio2=v.getValue();
var ds_random_employee_data_active2=ds_random_employee_data_active;
ds_random_employee_data_active2.load({ params: { anio: varAnio2 } });
Ext.each(ds_random_employee_data_active2.data.items, function(record){
alert(record.data.ut);
});
//setTimeout("tres("+ v +"[]);",1000);

}}



})
}
http://pastebin.com/RA600Pp7

Condor
22 Jul 2010, 10:05 AM
Why are you calling ds_random_employee_data_active.remove()?

It's simply a question of calling:

ds_random_employee_data_active.load({params: {anio: varAnio2}})

And remember: Loading is asynchronous. You have to wait for the server to respond before you can query the new records (e.g. in the load event handler or the load callback).

christian130
22 Jul 2010, 10:58 AM
thanks condor, i'm recently watching ur suggest. the remove method before it was removeAll and then i wrote remove for testing to see if there'd be a chance. Well it seem that i must wait, that means i have to figure out another way.
In short words what i'm trying to do is populate a grid according with two comboboxes which retrieve data from server. Well in deed there is just one that fetch data from server and is the most important! i'm almost done with that but what it keeps is that
i'll post an image for u to see what i'm trying to explain

http://img69.imageshack.us/i/pantallazo4z.png/
in the pic u'll see i have a grid
if u want to i'd like post more pic for u to got what my problem is

christian130
22 Jul 2010, 11:36 AM
[SOLVED] I ALREADY FIX THE PROBLEM
THE THING WAS THAT THERE IS A method/property (which in javascript is almost the same), named callback, so i defined like this
store.load({params:{anio:varanio},callback:function(){// here comes the loop or another instruction
}})
I'M THANKFUL WITH U CONDOR!!