10

我目前正在使用基于可编辑网格示例的 Extjs 4 网格组件。我想有一个与每个单元格相关联的链接,这样当我单击一个单元格时,它会将我带到另一个页面。但是,当单击链接时在页面上触发垂直滚动时。

例如尝试减小http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/cell-editing.html的大小,第一次单击网格会滚动页面,使网格位于中心和事件被吞没。您必须再次单击才能注册 cellclick 事件。这只发生在 IE 中(我使用的是版本 8)。好消息是其他浏览器不会发生这种情况,这可能是一个错误吗?有没有办法阻止第一次滚动操作发生?

谢谢

4

4 回答 4

12

我遇到了同样的问题,并在 Sencha 讨论板上找到了解决方案。

添加此代码确实对我有用:

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

更多信息: http ://www.sencha.com/forum/showthread.php?133983-How-to-prevent-extjs-grid-from-scrolling-when-clicking-on-a-cell

于 2011-09-13T16:13:48.433 回答
2

试试这个补丁

Ext.override(Ext.selection.RowModel, {
    onRowMouseDown: function(view, record, item, index, e) {
        //IE fix: set focus to the first DIV in selected row
        Ext.get(item).down('div').focus();

        if (!this.allowRightMouseSelection(e)) {
            return;
        }

        this.selectWithEvent(record, e);
    }
});
于 2012-03-19T10:27:30.120 回答
2

今天我在 ExtJS 4.2 上遇到了同样的问题,早期的解决方案对我不起作用,在网格面板上使用这个配置完全解决了这个问题:

viewConfig: {
    focusRow: Ext.emptyFn
}

例如:

Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
    viewConfig: {
        focusRow: Ext.emptyFn
    }
    columns: [
        { text: 'Name',  dataIndex: 'name' },
        { text: 'Email', dataIndex: 'email', flex: 1 },
        { text: 'Phone', dataIndex: 'phone' }
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});
于 2015-09-10T06:54:51.397 回答
1

这可能类似于这个问题:在 IE7 中,第一次单击网格会导致 ExtJS Ext.grid.GridPanel 跳转到页面顶部 尝试位置:相对;缩放:1 在网格周围的容器上给它 hasLayout

于 2011-05-19T16:18:20.547 回答