[ 2 posts ]

Leo Currie

  • Username: leo
  • Joined: Fri Jul 30, 2010 1:29 am
  • Posts: 7
  • Offline
  • Profile

oFullResponse.results in filterResults gets smaller

Post Posted: Mon Sep 06, 2010 5:09 am
+0-
Hi -

I'm trying to write a custom filterResults method for an AutoComplete. (Hope this is the right place to post this!)

My datasource is an XHRDataSource, I have applyLocalFilter set to true, as well as queryMatchSubset, and I've set maxCacheEntries to 5 and minQueryLength is 3. .

The problem that I'm seeing is if the user types too much, and gets too few matches, then deleting some characters doesn't always return the full set of matches for the characters visible.
Inside my custom filterResults, I can see that the oFullResponse.results array gets smaller the more the user types.

I am assuming that, contrary to my expectations, oFullResponse contains the cached filtered list, and not the original unfiltered response.

If that's correct, is there a way to override this in XHRDatasource so that the oFullResponse always contains the full list? Or do I need to extend functiondatasource to do this?

Thanks for your help.

Leo

Leo Currie

  • Username: leo
  • Joined: Fri Jul 30, 2010 1:29 am
  • Posts: 7
  • Offline
  • Profile

Re: oFullResponse.results in filterResults gets smaller

Post Posted: Thu Sep 23, 2010 7:50 am
+0-
In case anyone is interested, I've worked around this issue by keeping a reference to the original results field in the oFullResponse -
inside my custom filter code, I do this:

Code:

customFilter = function(sQuery, oFullResponse, oParsedResponse, oCallback) {
  if (oFullResponse._originalResults) {
    // restore the unfiltered results
    oFullResponse.results = oFullResponse._originalResults;
  } else {
    // keep a handle on the unfiltered results
    oFullResponse._originalResults = oFullResponse.results;
  }

  // now the actual filter code goes here

}


Not sure if this is the best way to do it, but it seems to work.
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum