frosty
frosty

Reputation: 5370

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

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.

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

Upvotes: 2

Views: 4881

Answers (2)

Alexey Fedorin
Alexey Fedorin

Reputation: 11

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;
    }
});

Upvotes: 1

Alex Tokarev
Alex Tokarev

Reputation: 4861

The standard feature works for me:

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

    viewConfig: {
        preserveScrollOnRefresh: true
    }
});

Upvotes: 4

Related Questions