PDA

View Full Version : To refer to column to a datastore but doesn't work



norizam61
2 May 2010, 8:49 PM
I defined the field in a form

_smrgid = new Ext.form.TextField({
xtype: 'textfield',
fieldLabel: 'IC No',
id: 'st_id',
name: 'st_id',
anchor:'95%'
});

_smrgnokp = new Ext.form.TextField({
xtype: 'textfield',
fieldLabel: 'IC No',
anchor:'95%'
});

_smrgnama = new Ext.form.TextField({
xtype: 'textfield',
fieldLabel: 'Name',
anchor:'95%'
});

I defined basic datastore


_smrg_data = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'app/php/smrg-manipulation.php'})
, reader: new Ext.data.JsonReader({ root: "data" },[ 'st_id', 'st_nama1', 'st_nokp'])
, remoteSort: false
});

I do load the datastore
_smrg_data.load({
params: {
action: 'Retrieve'
, id: text
}
});

I want to refer to each column in datastore like below but doesn’t work (it just doesn’t pass value), in firebug i successfully recall the data from database
_smrgid.setValue(_smrg_data.getAt(0).data.st_id);
_smrgnama.setValue(_smrg_data.getAt(0).data.st_nama1);
_smrgnokp.setValue(_smrg_data.getAt(0).data.st_nokp);

:(

Condor
2 May 2010, 10:01 PM
I assume you forgot that loading a store is ansynchronous.

You have to wait for the response to be received before you can access the data, e.g.

_smrg_data.load({
params: {
action: 'Retrieve',
id: text
},
callback: function(){
_smrgid.setValue(_smrg_data.getAt(0).get('st_id'));
_smrgnama.setValue(_smrg_data.getAt(0).get('st_nama1'));
_smrgnokp.setValue(_smrg_data.getAt(0).get('st_nokp'));
}
});

norizam61
2 May 2010, 10:36 PM
Condor

Thanks for the correct answer !

Norizam61