PDA

View Full Version : How to reload combobox every click?



Yazla
19 May 2009, 4:24 AM
Hi guys, i have problem. I need to refresh combobox(reload store) with JsonStore every time when user click drop down arrow. I found several solutions here, but no one helped. Maybe this is becouse of using custom PageMethodProxy.
So here is my code


var DataSourceProxy = new Ext.data.PageMethodProxy({ pageMethod: 'GetDatabases', start: 0, limit: 10 });


var DatasourceStore = new Ext.data.JsonStore({
proxy: DataSourceProxy,
autoload: true,
fields: ['DatabaseName']
});

var comboDataSource = new Ext.form.ComboBox({
store: DatasourceStore,
displayField: 'DatabaseName',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select a datasource...',
selectOnFocus: true,
width: 200,
editable: false
});


Code of PageMethodProxy


Ext.data.PageMethodProxy = function(config) {
Ext.data.PageMethodProxy.superclass.constructor.call(this);
Ext.apply(this, config);
};

Ext.data.PageMethodProxy.TRANS_ID = 1000;
Ext.data.PageMethodProxy.arr_trans = Array();

Ext.extend(Ext.data.PageMethodProxy, Ext.data.DataProxy, {
load: function(params, reader, callback, scope, arg) {
if (this.fireEvent("beforeload", this, params) !== false) {

var p = Ext.apply(params, this.extraParams);
var transId = ++Ext.data.PageMethodProxy.TRANS_ID;
var trans = {
id: transId,
params: params,
arg: arg,
callback: callback,
scope: scope,
reader: reader
};
eval("PageMethods." + this.pageMethod + "(this.handleResponse,this.handleError)");
Ext.data.PageMethodProxy.arr_trans[Ext.data.PageMethodProxy.TRANS_ID] = trans;
}
else {
callback.call(scope || this, null, arg, false);
}

},

isLoading: function() {
return this.trans ? true : false;
},

abort: function() {
if (this.isLoading()) {
this.destroyTrans(this.trans);
}
},

handleResponse: function(o, userContext, methodName) {
var trans = Ext.data.PageMethodProxy.arr_trans[Ext.data.PageMethodProxy.TRANS_ID];
var result;
try {
result = trans.reader.readRecords(o);
} catch (e) {
trans.scope.fireEvent('loadexception', this, o, trans.arg, e);
trans.callback.call(trans.scope || window, null, trans.arg, false);
return;
}
this.trans = false;
trans.callback.call(trans.scope || window, result, trans.arg, true);
}
,
handleError: function(error, userContext, methodName) {
var trans = Ext.data.PageMethodProxy.arr_trans[Ext.data.PageMethodProxy.TRANS_ID];
trans.scope.fireEvent('loadexception', this, null, trans.arg, error);
trans.callback.call(trans.scope || window, null, trans.arg, false);
return;
}
});

i have tried lastQuery ='' , and store.removeAll but nothing helped.
Can anybody help? Thanx a lot.

Cheers.

Yazla
19 May 2009, 8:08 AM
Finded solution: combobox.lastQuery = undefind, not combobox.lastQuery = ''.