PDA

View Full Version : Combo : how to manually display loadingText in LOCAL mode ?



pbaccari
29 Sep 2009, 9:11 AM
Hello,

I've a combo in local mode (mode: 'local') that i load with a Ext.Ajax.request and a combo.getStore().loadData() of the result.

I want to display the loadingText before my call of Ext.Ajax.request (to have a "mode: remote" effect).
How i can do this ?

Best regards.
pbaccari.

zhegwood
29 Sep 2009, 1:14 PM
Why not use mode: "remote"? This is exactly for what it's intended.

pbaccari
29 Sep 2009, 11:32 PM
I don't use "remote" because I use check results with errors management, and I've make functions which work with all objets (combo, tree, grid ...).

In case I load data on select of other combo, I would like to show that my combo is under loading ...

But, why ?

pbaccari
30 Sep 2009, 5:29 AM
Hello,

I've found a soluce :

1)
I override Ext.form.ComboBox with code found in "onBeforeLoad" :

Ext.override(Ext.form.ComboBox, {
showLoadingText: function () {
if (this.rendered && this.innerList != null) {
this.innerList.update(this.loadingText ? '<div class="loading-indicator">' + this.loadingText + '</div>' : '');
this.restrictHeight();
this.selectedIndex = -1;
}
}
});

So i could call my "showLoadingText" when i want.

2)
There's a problem whem the combo is empty, this.innerList return an error.
So, i add in the if condition of my function the second parts "&& this.innerList != null"

And, before calling "showLoadingText", I put in the combo a value like :

combo.getStore().loadData({
"data": [{
"id": "",
"libelle": "En cours de chargement ..."
}]
},
false);
combo.showLoadingText();


Please let me make comments for improvements or most appropriate method.

Best regards.
pbaccari