extjs 4.1 page scrolls to top of grid in internet explorer on row update

99封情书 提交于 2019-12-06 11:31:24

问题


On my grid i'm using rowediting.

if using Internet explorer 10 ( probably the other versions too ) and the page has scrollbars

When i edit a row and click "update" the page scrolls up to the start of the grid.

This issue is quite well documented on ( though not specifically on 4.1 ).

I've seen fixed that override rowModel like this

Ext.override(Ext.selection.RowModel, {
    onRowMouseDown: function(view, record, item, index, e) {
//        view.el.focus();
        this.selectWithEvent(record, e);
    }
}); 

I've also seen adding the following to the grid.

selModel: Ext.create('Ext.selection.Model', { listeners: {} }),

Neither of these options worked for me.

  • edit *

I've tried "preserveScrollOnRefresh: true" as suggested below. But the issue still remains. I've put an example on dropbox. To recreate this in internet explorer you will need to minimize the browser and click/edit on for items need the footer of the grid.

https://www.dropbox.com/s/l50d12t3cjq8kef/scrolling.htm


回答1:


The standard feature works for me:

Ext.define('My.Grid', {
    extend: 'Ext.grid.Panel',

    viewConfig: {
        preserveScrollOnRefresh: true
    }
});



回答2:


In case you are using CellModel or having problem with other solutions, this solution should work:

Ext.override(Ext.dom.Element, {
    focus: function (defer, dom) {
        var me = this,
            scrollTop,
            body;

        dom = dom || me.dom;
        body = (dom.ownerDocument || DOC).body || DOC.body;
        try {
            if (Number(defer)) {
                Ext.defer(me.focus, defer, me, [null, dom]);
            } else {
                if (dom.tagName != 'DIV') {
                    if (dom.offsetHeight > Ext.dom.Element.getViewHeight()) {
                        scrollTop = body.scrollTop;
                    }
                    dom.focus();
                    if (scrollTop !== undefined) {
                        body.scrollTop = scrollTop;
                    }
                }
            }
        } catch (e) {
        }
        return me;
    }
});


来源:https://stackoverflow.com/questions/11647095/extjs-4-1-page-scrolls-to-top-of-grid-in-internet-explorer-on-row-update

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!