【问题标题】:Disable Multi-Row selecton in ExtJS Grid在 ExtJS Grid 中禁用多行选择
【发布时间】:2015-03-26 13:32:13
【问题描述】:

SO 中已经有一个与我的问题类似的问题:

Ext js Editor Grid Disable Multiple Row Selection

但接受的答案是错误的。它说要使用 RowSelectionModel 作为这样的属性:

selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),

但是在 API 中不存在这样的东西(也许他们在谈论不同的 extjs 版本)。

如何在 Extjs 网格中禁用多选? IE。没有 SHIFT 或 CTRL 多选。只允许单选。

【问题讨论】:

    标签: extjs extjs4.2


    【解决方案1】:

    参考documentation

    它表明你可以像这样指定选择模型:

    默认情况下,网格使用行选择模型,但这很容易自定义,如下所示:

    Ext.create('Ext.grid.Panel', {
        selType: 'cellmodel',
        store: ...
    });
    

    或者替代选项是:

    Ext.create('Ext.grid.Panel', {
        selType: 'rowmodel',
        store: ...
    });
    

    编辑:

    您需要指定Selection Model MODE

    Fiddle

    Ext.application({
        name: 'MyApp',
    
        launch: function() {
            var store = Ext.create('Ext.data.Store', {
                storeId: 'simpsonsStore',
                fields: ['name', 'email', 'phone'],
    
                proxy: {
                    type: 'ajax',
                    url: 'data1.json',
                    reader: {
                        type: 'json',
                        rootProperty: 'items'
                    }
                },
                autoLoad: true
            });
    
    
            Ext.create("Ext.grid.Panel", {
                title: 'Simpsons',
                renderTo: Ext.getBody(),
                store: Ext.data.StoreManager.lookup('simpsonsStore'),
                selModel: new Ext.selection.RowModel({
                    mode: "SINGLE"
                }),
                columns: [{
                    text: 'Name',
                    dataIndex: 'name'
                }, {
                    text: 'Email',
                    dataIndex: 'email',
                    flex: 1
                }, {
                    text: 'Phone',
                    dataIndex: 'phone'
                }],
                height: 200,
                width: 400,
            });
    
        }
    
    });
    

    【讨论】:

    • 这不能回答我的问题。我正在尝试使用 SHIFT 或 CTRL 禁用多行选择
    猜你喜欢
    • 2012-06-24
    • 2018-03-13
    • 2013-06-17
    • 2018-09-18
    • 1970-01-01
    • 2013-02-13
    • 1970-01-01
    • 2019-03-26
    • 2020-08-24
    相关资源
    最近更新 更多