0

I have a Dojo FilteringSelect that takes about 20 seconds to load its values from the dB when the user clicks the arrow in the list box. I'd like to display a progress spinner while waiting for the data to be returned from the dB. Any ideas what event I would use to show my spinner when the data is being retrieved from the db and what event to hide the spinner when it completes? Thanks...

new FilteringSelect({
    store: new dojo.data.ItemFileReadStore({ url: "some url here" }),
    autocomplete: true,
    maxHeight: "300",
    required: false,
    id: "country_select_id",
    onChange: function(data) {
        dojo.byId("case_info_status").innerHTML = " ";
    }
}, "country_select_id"); 
Karl
  • 149
  • 3
  • 14

1 Answers1

0

I bet you could go a long way in the select._fetchHandle deferred and the store._fetchItems. Try this

var select = new .... Your FilteringSelect Construct( {} );

select._fetchHandle.addCallback(function() {
 // success callback
 dojo.style(dojo.byId('spinner'), "display", "none");

});

dojo.connect(select.store._fetchItems, function() {
   if(select.store._loadFinished) return; // no-op
   dojo.style(dojo.byId('spinner'), "display", "block");
});

EDIT:

select._fetchHandle will only be present briefly during the actual download (suppose we can hook onto it after select onOpen called). Instead, another private method in ItemFileReadStore comes in handy

dojo.connect(select.store._getItemsFromLoadedData, function() {
     dojo.style(dojo.byId('spinner'), "display", "none");
});
mschr
  • 8,531
  • 3
  • 21
  • 35
  • mschr,Thanks for the response and I tried your idea but I keep getting an error message that the "_fetchHandle is undefined". Any idea how I resolve that? I'm still trying to figure out this Dojo thing. Thanks – Karl Aug 23 '12 at 13:59
  • ahh sweet, just looked again - the original deferred handler onFetch inside the filteringselect sets the _fetchHandle = null immediately as it starts running..:q – mschr Aug 23 '12 at 16:15
  • Pardon my Dojo ignorance, but I take it that means I can't do what I want seeing as the _fetchHandle is set to null? – Karl Aug 23 '12 at 17:26
  • there is no real external event in the ItemFileReadStore for queing up function flows on end of a fetch. this is done via store.fetch({cbDeclaration}) - a couple of properties to fetch. The one internal *start* of fetch is `select.store._fetchItems`, use that to display an icon. The other internal *complete* of fetch is `select.store._getItemsFromLoadedData`, use connect on that as with the first to hide an icon – mschr Aug 23 '12 at 17:47