Results 1 to 5 of 5

Thread: TreeStore filterBy function fires on expand/collapse and check change

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2011
    Location
    Arvada, CO
    Posts
    404

    Default TreeStore filterBy function fires on expand/collapse and check change

    I have a search field for my TreePanel, and under the hood, all this search does is take what's entered, put it into a regex, and then use a filterBy function on the TreeStore, and it appears to work. However, I have noticed that this fitlerBy function fires every time something is done to the TreePanel... if the user checks a checkbox or expands/collapses a branch. This is not ideal, as my TreePanel can contain a good amount of records and having to do this on every action is expensive.

    To reproduce the issue:
    • Open debugger console
    • Type a character in the search box
    • Notice in filter debugger message fires 319 times
    • Check a parent checkbox
    • Notice there is a large amount of lag... this is because I am updating all of the child records every time a parent is checked... so the updating causes the lag, but I'm not sure how to prevent it

    I'm expecting the filter to not fire every time the user performs one of these actions... I'm only expecting the filter to fire when I apply the filterFn. Am I using the filterFn wrong, is this just an incredibly nasty side effect of filtering a treestore, or is this actually a bug/something that can be optimized?


  2. #2
    Sencha User
    Join Date
    Mar 2011
    Location
    Arvada, CO
    Posts
    404

    Default

    I can lighten the load drastically by doing the following:
    Code:
      onCheckChange: function(parent, checked, e, eOpts) {
        var store = this.getView().getStore();
        if (parent) {
          var cls = '';
          var disabled = false;
          if (checked) {
            cls = 'disable-child-node';
            disabled = true;
          }
          parent.eachChild(function(child) {
            child.beginEdit();
            child.set('cls', cls);
            child.set('disabled', disabled);
            child.endEdit(true);
          });
          this.getView().getView().refreshView();
        }
      }
    So instead of having each endEdit bubble up to the store to say refresh the view, I prevent any of it from bubbling up and refresh the view manually... filterBy function still fires, but it's only on the order of n, where n is the number of records in my store.

  3. #3
    Sencha User
    Join Date
    May 2015
    Posts
    13

    Default

    Any news about this bug? Even during loading the store filter function is called multiple times for each node. In trees with ~1000 items browser stops responding because of that...

  4. #4
    Ext JS Premium Member
    Join Date
    Jun 2007
    Posts
    125

    Default

    Quote Originally Posted by yisohec View Post
    Any news about this bug? Even during loading the store filter function is called multiple times for each node. In trees with ~1000 items browser stops responding because of that...
    Same here. Any work arounds for this issue? I tried suspending events for the tree and store and I still see this. It's worse when you have a parent node with multiple children nodes which are also parents. The filter fn is executed for each non-leaf node that's expanded n levels deep which kills performance. I'm on 6.0.2.

    Miro

  5. #5

    Join Date
    Jan 2008
    Location
    Levittown, PA
    Posts
    359

    Default

    This is still a bug in 6.5

    Somehow my treestore.filteryBy() was firing multiple times. I placed a counter in the filterBy function and what should have loop through 112 times was looping over 4000 time. I had an expandAll() after the filterBy at that point.

    I moved the expandAll() prior to the filterBy() and everything works as expected.

Similar Threads

  1. OnReady Fires Multiple Times With IFrames
    By superman859 in forum Ext: Q&A
    Replies: 2
    Last Post: 20 Dec 2012, 5:23 PM
  2. Function Called Multiple Times
    By SlimCubes in forum Ext: Discussion
    Replies: 2
    Last Post: 13 Jun 2012, 6:16 AM
  3. Replies: 6
    Last Post: 4 Jan 2012, 7:56 AM
  4. Replies: 0
    Last Post: 18 Feb 2011, 5:10 AM
  5. Grid row selection change fires multiple times the same events
    By khepri in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 7 Jul 2008, 5:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •