PDA

View Full Version : Problems while loading data into Combobox



deathzbr
14 Feb 2012, 3:35 PM
Hi guys,

I'm also new to Ext JS and I'm trying it out to replace jQuery on projects and obviosly I'm having trouble doing it. Currently what is keeping me stuck is trying to RE-load data from a Store into a Combobox.

Store code goes as follows:


var supplierStore = new Ext.data.Store({
model: 'supplierModel'
,autoLoad: false
,proxy: {
type: 'ajax'
,url: '/Webservice.aspx?QueryTemplate=Capacity%2FSelectSupplierPlant&IsTesting=T&Content-Type=text%2Fxml'
,reader: {
type: 'xml'
,record: 'Row'
,idProperty: 'ID'
}
}
});


This store is build with a Webservice that I have that returns a XML structure from a SQL query.

Then I have a combo box that uses this store as follows:


{columnWidth: .36
,border: false
,items:[{
xtype: 'combo'
,fieldLabel: 'Supplier'
,store: supplierStore
,width: 336
,labelWidth: 80
,valueField: 'ID_SUPPLIER'
,displayField: 'DS_SUPPLIER'
,queryMode: 'local'
,lastQuery: null
,triggerAction: 'all'
,id: 'comboSupplier'
,ready: false
}]
}

Now my problem is, sometimes I have to pass one parameter to the store in order to change the suppliers available for my datacenter, so I do it with the following command:



var datacenter = Ext.getCmp('datacenter').getValue();
Ext.apply(supplierStore.getProxy().extraParams, {
'Param.1' : datacenter
});
supplierStore.load();



When I do this, the suppliers Combobox is actually reloaded with the correct informatoin, but there is a Loading mask in front of it that will NOT go away.

What can I do?

Thanks and Best regards,

Guilherme

dedoz
14 Feb 2012, 8:38 PM
1) ExtJs version ?
2) use Ext.create instead new Someclass
3) full code should help

if you are doing
supplierStore.load()
Ext.create(
.. some view that uses combox supperStore and queryMode : local ...
)
remember the store is loading asynchronus and then you create a combobox that thinks the store is already loaded, since says "local" means the data is already there. and when the combobox is goin to read the store, the store is loading, and strange stuff happens.

try creating the view/combox after the first supplierstore.load()
just to test try doing
Ext.define('SupplierStore',{
extends : 'Ext.data.Store',
model : 'suppliermodel',
... other configs ...
})
myStore = Ext.create('supplierStore');
myStore.load({
callback : function()
{ Ext.create(' the view where you are using the combox and the store')
}
})

like this, combobox wont have problems using the store, its created after the store is loaded and combobox can read the data as local.

in the later myStore.load() you dont have to create the combobox of course.
try that just to test, and if everything works is because combobox is a bit broken in the last versions of ExtJs,
normally im using something like (inside a class)

loadStores: function()
{ this.myStore = Ext.create('someStore');
this.myStore.load({callback:this.storesReady, scope:this})
},

storesReady : function()
{ Ext.create('create any component that needs the store loaded first')
}

YomeKitsuma
15 Feb 2012, 12:04 AM
This points to my "issue".

The thing we have to remember is "asynchronously loading" !!!

~o)

But does the callBack function also takes care about "relations" in a store (ie. belongsTo or hasMany) ?