【问题标题】:Ext 4 RowEditor editing cancels when first time click on ComboBox in currently edited row第一次单击当前编辑行中的 ComboBox 时,Ext 4 RowEditor 编辑取消
【发布时间】:2012-08-22 07:19:47
【问题描述】:

我有一个带有 RowEditor 插件的Ext.grid.Panel,它包含一个带有组合框编辑器的列:

    {
        dataIndex: 'parentId',
        text: 'Parent category',
        editor: {
            store: store,
            valueField: 'categoryId',
            displayField: 'name',
            xtype: 'combobox',
            allowBlank: true
   }

商店是这样的:

var store = Ext.create('Ext.data.Store', {
    model: 'Category',
    autoLoad: true,
    proxy: {
        type: 'rest',
        url: 'api/categories',
        reader: {
            type: 'json',
            root: 'categories'
        }
    }
});

和型号:

Ext.define('Neopod.model.Category', {
    extend: 'Ext.data.Model',
    fields: ['categoryId', 'name', 'parentId'],
})

当第一次编辑网格行并单击组合框时,ExtJS 会触发从服务器加载数据,并且 roweditor 会自动取消。所以用户希望看到组合下拉菜单,但组合没有打开,而是取消了编辑模式。

那么为什么 ExtJS 会这样呢?

【问题讨论】:

    标签: javascript extjs extjs4


    【解决方案1】:

    一个简单的处理方法是使用:queryMode: 'local' 配置您的组合框,这样它就不会在展开时尝试重新加载。

    使用您的示例:

    {
        dataIndex: 'parentId',
        text: 'Parent category',
        editor: {
            store: store,
            valueField: 'categoryId',
            displayField: 'name',
            xtype: 'combobox',
            allowBlank: true,
            queryMode: 'local'
       }
    }
    

    您也可以尝试使用autoCancel: false 配置您的RowEditing 插件,例如:

    Ext.create('Ext.grid.plugin.RowEditing', {
        pluginId: 'rowediting',
        clicksToEdit: 2,
        autoCancel: false
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多