Results 1 to 3 of 3

Thread: store.getById only searching local data

  1. #1
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    117
    Answers
    3

    Question Answered: store.getById only searching local data

    ExtJS v4.1.3

    I have a paged GridPanel, and I need to find (and highlight) an entry, that may not have been loaded yet. I do know that the Id exists in the store.

    I've tried programmatically loadPage(store.currentPage + 1), until I find the record, but given that the calls are asynchronous, it's not working for me.

    Any suggestions for a good/better approach to this?

    Thanks.

    -Chris

  2. you can add a listener 'on' load event and then when the event is fired, you can check if your record has been loaded or not. if not, you can load the next page. when you find the record, remove the listener using 'un'.

    Code:
    var totalCount = store_result.getTotalCount();
    var pageCount = Math.ceil(totalCount / store_result.pageSize);
    i = 1;
    
    store.on('load', function() {
      if(store.findRecord("id", id))  // if record is found, remove listener
        store.un('load',arguments.callee);
      else
      {
        if(i < pageCount)
        {
          i++;
          store.loadPage(i);
        }
      }
    });

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    you can add a listener 'on' load event and then when the event is fired, you can check if your record has been loaded or not. if not, you can load the next page. when you find the record, remove the listener using 'un'.

    Code:
    var totalCount = store_result.getTotalCount();
    var pageCount = Math.ceil(totalCount / store_result.pageSize);
    i = 1;
    
    store.on('load', function() {
      if(store.findRecord("id", id))  // if record is found, remove listener
        store.un('load',arguments.callee);
      else
      {
        if(i < pageCount)
        {
          i++;
          store.loadPage(i);
        }
      }
    });

  4. #3
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    117
    Answers
    3

    Default

    Thanks, that's working well.

Tags for this Thread

Posting Permissions

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