在ExtJS网格面板中,如何使用ChainedStore和widgetcolumn来显示每行具有不同值的组合框

In an ExtJS gridpanel, how to use ChainedStore and widgetcolumn to show comboboxes with different values in each row

本文关键字:显示 组合 widgetcolumn 网格 ExtJS ChainedStore 何使用      更新时间:2023-09-26

对于ExtJS 5和6,链式存储是源存储的"视图"。连锁商店可以进行分类;在不影响源存储的情况下独立筛选。

var mySourceStore = Ext.create('Ext.data.Store', {
    fields: ['id', 'name']
}); 
var myChainedStore = Ext.create('Ext.data.ChainedStore', {
    source: mySourceStore
});

并且gridpanel也可以使用widgetcolumn有一个带有组合框的列。

{
    xtype: 'widgetcolumn',
    text: 'all combos',
    widget: {
        xtype         : 'combobox',
        store         : myChainedStore,
        valueField    : 'id',
        displayField  : 'name',
        forceSelection: true
    }
}

我需要的是每一行都有一个连锁商店的实例。根据行中的其他值,将对链接存储进行过滤。实际上,每行中的组合框可能会显示一组不同的值。

使用小部件列和连锁商店来实现这是一个好方法吗?这样的解是什么样的呢?

PS:为了记录,这些是我发现的其他方法来完成类似的事情:

  • 如何为网格中的每个单元格组合框编辑器定义不同的存储?
  • https://www.sencha.com/forum/showthread.php?60618-different-values-for-a-ComboBox-on-each-row-of-an-EditorGrid

可以使用以下命令创建store实例:

{
xtype: 'widgetcolumn',
text: 'all combos',
widget: {
    xtype         : 'combobox',
    store         : Ext.create('Ext.data.ChainedStore'),
    valueField    : 'id',
    displayField  : 'name',
    forceSelection: true
}

}