开发者

Applying filter to my store causes grid to refresh with incorrect data set temporarily

I have a very simple interface containing a grid, a search field, a search button and a data store from a JSON data source.

The default state of the grid is showing all the data for the given user and entering a term in the search field and clicking the search button applies a filter which then re-executes a call to fetch a new JSON result set and put that data in the grid. I'm doing so the following way:

quick_search: function(search_term, store) {                                                                                                                                    
  store.clearFilter(true);                                                                                     开发者_开发问答                                                                 
  store.filter([{property: 'filter', value: search_term}]);                                                                                                                     
}

The following function is executed just fine when the search button is clicked, but I'm seeing this scenario:

  • User starts with 100 records in the grid
  • User searched for "test" (has 25 records)
  • The appropriate 25 records show in the grid
  • User then searches for "stack" (45 results)
  • The grid quickly shows the original 100 records momentarily and then shows the correct 45 records

And when that last step occurs, it's a very quick blip.

Is this the correct pattern for re-freshing grid data on the fly in a search-esque way? Am I perhaps incorrectly clearing the filter?


Found the solution... Previous solution was trying to run load and was resulting in multiple requests back to my webserver fetching multiple result sets (first the incorrect, then the correct).

quick_search: function(search_term, store) {
  store.filters.clear();                                                                                                                                    
  store.filter([{property: 'filter', value: search_term}]);                                                                                                                     
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜