Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Inheritance Extjs继承异常行为_Inheritance_Extjs - Fatal编程技术网

Inheritance Extjs继承异常行为

Inheritance Extjs继承异常行为,inheritance,extjs,Inheritance,Extjs,我在Extjs中有继承,我希望子类属性与父类属性(本例中为列)合并 两个问题: 1) 我正在尝试将“子列”属性与父列合并,合并部分起作用,它添加了其他列,但从父列中删除了第一个列。请参见JSFIDLE以了解模拟 2) 当我渲染网格及其父网格并单击排序时,两个网格都已排序。这就像一场碰撞 谢谢 我认为您需要克隆父列,并在本例中使用推送: initComponent: function () { var clonedParentColumns = Ext.clone(this.superc

我在Extjs中有继承,我希望子类属性与父类属性(本例中为列)合并

两个问题:
1) 我正在尝试将“子列”属性与父列合并,合并部分起作用,它添加了
其他
列,但从父列中删除了第一个列。请参见JSFIDLE以了解模拟

2) 当我渲染网格及其父网格并单击排序时,两个网格都已排序。这就像一场碰撞

谢谢

  • 我认为您需要
    克隆
    父列,并在本例中使用
    推送

    initComponent: function () {
        var clonedParentColumns = Ext.clone(this.superclass.columns);
    
        clonedParentColumns.push({
            text: 'Other',
            dataIndex: 'other'
        });
    
        this.columns = clonedParentColumns;
    
        this.callParent(arguments);
    }
    

  • 父项和子项都使用相同的
    存储
    。(在本例中,将为其中的每一个创建一个存储:)

  • 用于将一个对象的属性合并到另一个对象。但是,网格是列配置对象的数组

    因此,您只需将额外的列配置对象推送到阵列:

    initComponent: function() {
        this.columns.push({
            text: 'Other',
            dataIndex: 'other'
        });
    
        this.callParent(arguments);
    }
    

    关于你的第二个问题,已经提到,如果你不想在两个网格上都应用分拣机和过滤器,你需要使用不同的存储。

    谢谢,你的示例没有添加
    其他
    字段。我的问题有两个子问题。谢谢你,伙计@Shazam:
    Other
    字段被添加到子网格中。
    initComponent: function() {
        this.columns.push({
            text: 'Other',
            dataIndex: 'other'
        });
    
        this.callParent(arguments);
    }