Triggering collection updates when adjusting filters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alasdaircr
    Active Community Member
    • Aug 2014
    • 525

    Triggering collection updates when adjusting filters

    How would I go about enabling automatic updates of search results while adjusting filters while looking at a list view.

    e.g. type text into a varchar filter and hit return, adding a link to a linkMultiple filter, setting a varchar to 'Is Empty' versus 'Is not Empty'.

    I would like any change to trigger a (rate-limited) automatic refetch of the collection. Currently this works already for boolean types, just not any others, and it only works when the filter is added, not when it is subsequently changed.

    I added a listenTo(view, 'change') handler in views/record/search::createFilter() however the changes are not bubbling up (persumably because of the nested views). I then looked at bull.js and added listeners to all the nestedViews, some change events do bubble up however this feels like overkill as I only want this behaviour while in mode == 'search'.

    I can handle the logic around rate limiting fine, I'm just unable to think of the cleanest way to detect ANY changes in a field while in search mode.

    Should I hook into the reRender calls somehow? Any other suggestions?
  • alasdaircr
    Active Community Member
    • Aug 2014
    • 525

    #2
    Actually I think I found it. I'm using a private method (bad perhaps) but am calling this._parentView.trigger('change') and the events are bubbling up to the search view. It's working pretty well.

    I'm tidying up and will submit a patch.

    Comment

    • alasdaircr
      Active Community Member
      • Aug 2014
      • 525

      #3
      Automatically refetches collection while adjusting filters in list views Uses throttling of 450ms to avoid hammering the backend with too many requests. There's probably one or two field types ...

      Comment

      • wtconseil
        Active Community Member
        • Apr 2015
        • 335

        #4
        the PR is still in open status ?
        (i had the same need)

        Will it be merged?

        Comment

        Working...