ExtJS 动态过滤 ComboBox

ExtJS filter ComboBox dynamically

我有一个包含多个组合框的 属性 网格,我想根据前一个框中 select 编辑的内容过滤一个框中的值。

我的代码如下所示:

var tempPropGrid = me.getView().add(
    {
        xtype:'propertygrid',
        width: 80,
        header: false,
        title: 'prop grid',
        //for some reason the headers are not hiding, we may need to deal with this using CSS
        //hideHeaders: true,
        enableColumnResize: false,
        sortableColumns: false,
        nameColumnWidth: 1,
        source: record.data,
        sourceConfig: {
            teamName: {
                editor: Ext.create('Ext.form.ComboBox', {
                    store: teams,
                    queryMode: 'local',
                    displayField: 'teamName',
                    valueField: 'teamName'
                }),
                displayName: 'Team'
            },
            leadDev : {
                editor: Ext.create('Ext.form.ComboBox', {
                    store: teamMembers.filter('teamName', teamName.value), // this probably won't work but you get the idea
                    queryMode: 'local',
                    displayField: 'personName',
                    valueField: 'personName'
                }),
                displayName: 'Lead Dev'
            },

我的 JSON 对象如下所示:

{
                    "periodName": "Week1",
                    "teamName": "tango",
                    "roleName": "SWE III",
                    "roleExperience": "3",
                    "id": "21ea7f61-a9a5-4dbd-b405-e7a0449f8096"
                },

所以基本上我是将一个项目分配给一个团队,然后根据我选择的团队,我想 select 一个基于他们在该团队中的领导开发人员。

我不确定如何提取组合框的值并动态应用过滤器,所以任何帮助都会很棒。

网格中的每一行都是一个模型。因此,在您的 leadDev 组合框中,您只需要侦听 'expand' 事件,然后检索当前行模型并将该模型的值应用于过滤器。 它应该看起来像这样(未选中):

Ext.create('Ext.form.ComboBox', {
                store: store
                queryMode: 'local',
                displayField: 'personName',
                valueField: 'personName',
                listeners: {
                    'expand' : function(combo) {
                         var grid = combo.up('grid');
                         var selection = grid.getSelectionModel().getSelection();
                         var currentRowModel = //get this from selection
                         combo.getStore().clearFilter(true);
                         combo.getStore().filter('teamName',currentRowModel.teamName);
                     }
                }
            })

当用户从第一个组合框中选择值时,您需要更新当前模型