Results 1 to 2 of 2

Thread: [DOCS]Ext.data.BufferedStore -> beforeload & load events

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-22825 in 6.2.2.
  1. #1
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default [DOCS]Ext.data.BufferedStore -> beforeload & load events

    hi guys,

    http://docs.sencha.com/extjs/6.0.2-c...ent-beforeload

    the docs say that you get the arguments store , operation , eOpts
    which is true for not buffered stores.

    buffered stores do not get the operation, only an options object
    (which is a bit useless, since it does not include filters, groupers, sorters)

    Code:
        reload: function(options) {
            var me = this,
                data = me.getData(),
                // If we don't have a known totalCount, use a huge value
                lastTotal = Number.MAX_VALUE,
                startIdx, endIdx, startPage, endPage,
                i, waitForReload, bufferZone, records;
    
            if (!options) {
                options = {};
            }
    
            // Prevent re-entering the load process if we are already in a wait state for a batch of pages.
            if (me.loading || me.fireEvent('beforeload', me, options) === false) {
                return;
            }
      
            //...
    Code:
        loadToPrefetch: function(options) {
            var me = this,
                prefetchOptions = options,
                i,
                records,
                dataSetSize,
    
                // Get the requested record index range in the dataset
                startIdx = options.start,
                endIdx = options.start + options.limit - 1,
                rangeSizeRequested = (me.getViewSize() || options.limit),
    
                // The end index to load into the store's live record collection
                loadEndIdx = Math.min(endIdx, options.start + rangeSizeRequested - 1),
    
                // Calculate a page range which encompasses the requested range plus both buffer zones.
                // The endPage will be adjusted to be in the dataset size range as soon as the first data block returns.
                startPage = me.getPageFromRecordIndex(Math.max(startIdx - me.getTrailingBufferZone(), 0)),
                endPage = me.getPageFromRecordIndex(endIdx + me.getLeadingBufferZone()),
    
                data = me.getData(),
                callbackFn = function () {
                    // See comments in load() for why we need this.
                    records = records || [];
    
                    if (options.loadCallback) {
                        options.loadCallback.call(options.scope || me, records, operation, true);
                    }
    
                    if (options.callback) {
                        options.callback.call(options.scope || me, records, startIdx || 0, endIdx || 0, options);
                    }
                },
                fireEventsFn = function () {
                    me.loadCount = (me.loadCount || 0) + 1;
                    me.fireEvent('datachanged', me);
                    me.fireEvent('refresh', me);
                    me.fireEvent('load', me, records, true);
                },
                // Wait for the viewable range to be available.
                waitForRequestedRange = function() {
                    if (me.rangeCached(startIdx, loadEndIdx)) {
                        me.loading = false;
                        records = data.getRange(startIdx, loadEndIdx + 1);
                        data.un('pageadd', waitForRequestedRange);
    
                        // If there is a listener for guaranteedrange then fire that event
                        if (me.hasListeners.guaranteedrange) {
                            me.guaranteeRange(startIdx, loadEndIdx, options.callback, options.scope);
                        }
    
                        callbackFn();
                        fireEventsFn();
                    }
                }, operation;
    
            //<debug>
            if (isNaN(me.pageSize) || !me.pageSize) {
                Ext.raise('Buffered store configured without a pageSize', me);
            }
            //</debug>
    
            // Ensure that the purgePageCount allows enough pages to be kept cached to cover the
            // requested range. If the pageSize is very small we might need a lot of pages.
            data.setMaxSize(me.calculatePageCacheSize(rangeSizeRequested));
    
            if (me.fireEvent('beforeload', me, options) !== false) {
            //...
    Best regards
    Tobias Uhlig

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report! I have opened a documentation bug in our bug tracker.

Similar Threads

  1. [INFOREQ] Ext.data.BufferedStore fails to load required pages
    By Trevor4001 in forum Ext JS 6.x Bugs
    Replies: 2
    Last Post: 19 Aug 2016, 3:05 PM
  2. Replies: 1
    Last Post: 17 Mar 2015, 4:42 AM
  3. Replies: 1
    Last Post: 6 Jan 2014, 6:43 AM
  4. Replies: 5
    Last Post: 20 Apr 2011, 4:40 PM
  5. Replies: 2
    Last Post: 29 Mar 2010, 7:27 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
  •