ExtJS多选编辑--无法进行多值选择。

问题描述 投票:2回答:1

我有一个GridEditPanel,其中第1列是一个带有多重选择的组合框。这些值被正确地从DB中加载,并且也被正确地写入DB中。在组合框只有一个值的情况下,下拉框也能正确地突出显示该值。

问题是当组合框有多个值时,它能正确地显示这些值,但在编辑时,多个值没有被选中。

模型。

extend: 'Ext.data.Model',
idProperty: 'contactTypeID',
fields: [
    {
        name: 'contactTypeID',
        type: 'string'
    },
    {
        name: 'contactType',
        type: 'string'
    }
],

查看GridEditPanel

emptyText: "There are no contacts.",
insertErrorText: 'Please finish editing the current contact before inserting a new record',
addButtonText: 'Add Contact',

itemId: 'contacts',
viewConfig: {
    deferEmptyText: false
},
minHeight: 130,

initComponent: function () {
    var me = this,
        contactTypes;

    // Creating store to be referenced by column renderer
    contactTypes = Ext.create('Ext.data.Store', {
        model: '********',
        autoLoad: true,
        listeners: {
            load: function () {
                me.getView().refresh();
            }
        }
    });

    this.columns = [
        {
            text: 'Contact Role',
            dataIndex: 'contactRoleID',
            flex: 1,
            renderer: function (value) {
                // Lookup contact type to get display value
                //If a contact has multiple roles, use split by ',' to find display values.
                if (value.includes(',')) {
                    var a = value.split(','), i, contTypeIds = [];
                    var contTypes = new Array();

                    for (i = 0; i < a.length; i++) {
                        contTypeIds.push(a[i]);
                        contTypes.push(contactTypes.findRecord('contactTypeID', a[i], 0, false, false, true).get('contactType'));
                    }
                    console.log('Multi Render Return Value: ' + contTypes);
                    return contTypes;
                }
                else {//if not a contact will only have one role.
                    var rec = contactTypes.findRecord('contactTypeID', value, 0, false, false, true); // exact match
                    console.log('Single Render Return Value: ' + rec.get('contactType'));
                    return rec ? rec.get('contactType') : '<span class="colselecttext">Required</span>';
                }
            },
            align: 'center',
            autoSizeColumn: true,
            editor: {
                xtype: 'combobox',
                store: contactTypes,
                multiSelect: true,
                delimiter: ',',
                forceSelection: true,
                queryMode: 'local',
                displayField: 'contactType',
                valueField: 'contactTypeID',
                allowBlank: false
            }
        },
extjs4.2
1个回答
0
投票

我不能看到GridEditPanel的模型,但我假设你使用了错误的字段类型,是字符串而不是数组(请查看 变流器 函数,也许它能帮助你解决问题)。) 我写了一个小的 岗位 在我的博客中,关于可编辑网格中的多选择组合框编辑器。该示例适用于v4.2希望它能帮助你修复这个错误。

© www.soinside.com 2019 - 2024. All rights reserved.