Extjs 作为网格编辑器的容器控件不更新值

Extjs 作为网格编辑器的容器控件不更新值,extjs,extjs4.1,gridpanel,Extjs,Extjs4.1,Gridpanel,所以我有一个两列的网格,第一列只有文本,第二列需要一个自定义控件(带有复选框和组合框) 检查屏幕: 以下是一个屏幕链接: 问题: 当我单击“更新”以更新行时。第一列会更新,但第二列不会更新 我天真地在自定义控件中添加了一个getValue(),但运气不好!!(注意:我正在使用行编辑插件) 这是我的密码: Ext.define('MainGrid', { extend: 'Ext.grid.Panel', //defs for all the toolbars and butto

所以我有一个两列的网格,第一列只有文本,第二列需要一个自定义控件(带有复选框和组合框)

检查屏幕:

以下是一个屏幕链接:

问题

当我单击“更新”以更新行时。第一列会更新,但第二列不会更新

我天真地在自定义控件中添加了一个
getValue()
,但运气不好!!(注意:我正在使用行编辑插件)

这是我的密码:

Ext.define('MainGrid', {
    extend: 'Ext.grid.Panel',
    //defs for all the toolbars and buttons
    plugins: [rowEditing],
    columns: [
                {
                    xtype: 'rownumberer'
                },
                {
                    xtype: 'gridcolumn',
                    text: 'Column Titles',
                    dataIndex: 'ColumnTitle',
                    editor: {
                        xtype: 'textfield',
                    }
                },
                {
                    xtype: 'gridcolumn',
                    sortable: false,
                    align: 'center',
                    dataIndex: 'IssueCondition',
                    editor: {
                        xtype: 'reportpopulation'
                    }]
});
reportpopulation
是这里的自定义控件。下面是它的代码:

Ext.define('SelectPopulation', {
    extend: 'Ext.container.Container',
    itemId: 'ctrSelectpopulation',
    alias: 'widget.reportpopulation',
    layout: {
        type: 'hbox'
    },
    initComponent: function () {
      //code to add combo box and checkbox snipped
      ....
    },
    getValue: function () {
        //This doesn't work! 
        return "Booo";
    }
});
因此,单击“更新”不会:

  • 有什么我遗漏的吗
  • 我应该从野战基地继承吗?我可以使用多个控件创建类似于FieldBase的screenie吗

这是可行的,即使您的
getValue()
也可以工作,问题是您在网格列(
IssueCondition
)上使用了自定义类型值,但没有为其指定任何渲染器,请尝试以下操作:

Ext.define('MainGrid', {
extend: 'Ext.grid.Panel',
height: 300,
plugins: [Ext.create('Ext.grid.plugin.RowEditing', {
    clicksToEdit: 1
})],
columns: [{
    xtype: 'rownumberer'
}, {
    xtype: 'gridcolumn',
    text: 'Column Titles',
    dataIndex: 'ColumnTitle',
    editor: {
        xtype: 'textfield'
    }
}, {
    xtype: 'gridcolumn',
    sortable: false,
    text: "Issue Condition",
    align: 'center',
    dataIndex: 'IssueCondition',
    width: 200,
    editor: {
        xtype: 'reportpopulation'
    },
    renderer: function (v, attr, rec) {
        console.info(arguments);
        return 'cb: ' + rec.data.IssueCondition.cb + ' combo: ' + rec.data.IssueCondition.combo;
    }
}],
store: Ext.create("Ext.data.Store", {
    fields: ["ColumnTitle", "IssueCondition"],
    proxy: {
        type: "memory",
        reader: {
            type: "json"
        }
    }
})
});

Ext.define('SelectPopulation', {
extend: 'Ext.container.Container',
itemId: 'ctrSelectpopulation',
alias: 'widget.reportpopulation',
layout: {
    type: 'hbox'
},
initComponent: function () {
    Ext.apply(this, {
        items: [{
            xtype: "checkbox"
        }, {
            xtype: "combobox",
            allowBlank: false,
            store: [
                [0, 'Zero'],
                [1, 'One'],
                [2, 'Two']
            ]
        }]
    });
    this.callParent(arguments);
},
getValue: function () {
    return {
        cb: this.child('checkbox').getValue(),
        combo: this.child('combobox').getValue()
    };
}
});
请注意,这只是一个例子


希望这能有所帮助。

第一列未绑定到任何字段(dataIndex)且有效,第二列绑定到IssueCondition且无效。。。嗯。。。你能和我分享你的模型吗(如果没有模型的话也可以去商店)@lontivero这只是我在这里发布代码时的一个输入错误。我更新了问题。猜猜为什么第二列没有显示任何数据?是因为它是一个容器控件吗?第二列没有显示任何数据,因为它不知道如何呈现该字段的“复杂”值,请检查我的答案。如果答案解决了您的问题,请接受它,谢谢。