【问题标题】:extjs disable cell editingextjs 禁用单元格编辑
【发布时间】:2012-06-18 05:09:12
【问题描述】:

如何禁用 xml 数据文件中的特定单元格编辑?

像这样:

<price disabled="true">9.37</price>

请给我一些例子 提前致谢

【问题讨论】:

    标签: extjs


    【解决方案1】:

    首先,要从 XML 响应中读取属性,您需要在模型中包含一个字段,该字段具有 mapping 配置到属性,请参阅 this post。在你的情况下是这样的:

    Ext.define('yourApp.model.Price', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'price',     type: 'float'},
            {name: 'disabled',  type: 'boolean',  mapping: 'price/@disabled'}
        ]
    });
    

    自从我使用 XML 响应以来已经有一段时间了,所以您可能不得不尝试一下。

    那么,如果记录的 disabled 字段为真,您只需在网格面板的 beforeedit 事件中添加检查以防止编辑。

    如果您使用的是 MVC 模式,它会是这样的:

    // controllers init function
    init: function() {
    
        this.control({
    
            'yourgridpanel': {
    
                // prevent disabled edits
                beforeedit: function(plugin, edit) {
    
                    if (edit.record.get('disabled')) {
                        return false;
                    }
                }
            }
        });
    }
    

    如果您不使用 MVC 模式,则处理程序将如下所示:

    yourGridPanel.on('beforeedit', function(plugin, edit) {
        if (edit.record.get('disabled')) {
            return false;
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 2014-11-05
      • 1970-01-01
      • 2013-09-13
      • 2016-07-15
      相关资源
      最近更新 更多