extjs 启用锁定的缓冲渲染器无法正常工作EXT Js

nhjlsmyf  于 2023-01-08  发布在  其他
关注(0)|答案(1)|浏览(146)

我正在使用一个有大量记录的网格。但是当我使用带启用锁定的缓冲渲染时,它不会打印所有记录。下面是上面的小技巧。https://fiddle.sencha.com/#fiddle/39sd&view/editor如果您注解“enableLocking:true”,它将打印所有记录,否则它将显示有限的记录。我想同时使用锁定和缓冲。我该如何做到这一点?

ubbxdtey

ubbxdtey1#

问题是来自Ext.grid.plugin.BufferedRenderer的init函数依赖于view.lockingPartner,而后者在调用init时是未定义的。
此覆盖修复了问题

Ext.define('BufferedRendererInit', {
    override: 'Ext.grid.plugin.BufferedRenderer',
    
    // Initialize this as a plugin
    init: function(grid) {
        var me = this,
            view = grid.view,
            viewListeners = {
                beforerefresh: me.onViewBeforeRefresh,
                refresh: me.onViewRefresh,
                columnschanged: me.checkVariableRowHeight,
                scope: me,
                destroyable: true
            },
            scrollerListeners = {
                scroll: me.onViewScroll,
                scope: me
            },
            initialConfig = view.initialConfig;
        
        //start override
        //original code: view.lockingPartner is undefined.
        //me.scroller = view.lockingPartner ? view.ownerGrid.scrollable : view.getScrollable();
        var isLockingOwnerGrid = view.ownerGrid && view.ownerGrid.lockedGridConfig && view.ownerGrid.normalGridConfig;
        me.scroller = isLockingOwnerGrid ? view.ownerGrid.scrollable : view.getScrollable();
        //end override
        
        // If we are going to be handling a NodeStore then it's driven by node addition and removal,
        // *not* refreshing. The view overrides required above change the view's onAdd and onRemove
        // behaviour to call onDataRefresh when necessary.
        if (grid.isTree || (grid.ownerLockable && grid.ownerLockable.isTree)) {
            view.blockRefresh = false;
            // Set a load mask if undefined in the view config.
            if (initialConfig && initialConfig.loadMask === undefined) {
                view.loadMask = true;
            }
        }
        if (view.positionBody) {
            viewListeners.refresh = me.onViewRefresh;
        }
        me.grid = grid;
        me.view = view;
        me.isRTL = view.getInherited().rtl;
        view.bufferedRenderer = me;
        view.preserveScrollOnRefresh = true;
        view.animate = false;
        // It doesn't matter if it's a FeatureStore or a DataStore.
        // The important thing is to only bind the same Type of store in future operations!
        me.bindStore(view.dataSource);
        // Use a configured rowHeight in the view
        if (view.hasOwnProperty('rowHeight')) {
            me.rowHeight = view.rowHeight;
        }
        me.position = 0;
        me.viewListeners = view.on(viewListeners);
        // Listen to the correct scroller. Either the view's one, or of it is
        // in a lockable assembly, the y scroller which scrolls them both.
        // If the view is not scrollable, this will be falsy.
        if (me.scroller) {
            me.scrollListeners = me.scroller.on(scrollerListeners);
        }
    }
});

相关问题