首页 > 解决方案 > Extjs 现代工具包 6.5.2 Triton 绑定多选字段

问题描述

我试图在现代工具包中模拟经典工具包中存在的标签字段,我找到了两种方法:

https://github.com/facilitiesexchange/TagField/

ExtJs 6 现代工具包多选字段

我以这种方式使用了这两种方式:

{
    xtype:'multiselectfield', //tagfield
    multiSelect: true,
    displayField: 'name',
    required: true,
    store: [
        { name: 'Peter',  age: 26 },
        { name: 'Ray',   age: 21 },
        { name: 'Egon', age: 24 },
        { name: 'Winston', age: 24 }
     ],
    label : 'People'
}

第一个自定义字段用于显示我商店中的数据,但我没有绑定选定的值。

第二个抛出了一些错误,当修复它们时它根本没有显示我商店中的任何值,所以我没有机会绑定选定的值。

所以我想知道如何将多选字段中的选定值与我的 viewModel 绑定。这是我的小提琴:https ://fiddle.sencha.com/#view/editor&fiddle/2lf0

标签: javascriptextjsmulti-selectextjs6extjs6-modern

解决方案


选择如下:

{
   xtype: 'tagfield',
   itemId: 'tagfield',
   multiSelect : true,
   displayField: 'name',
   valueField: 'id',
   bind: {
       label: '{i18n.topic.topics} ',
       store: '{topics}',
       selected: '{record.topics}'
   },
}

推荐阅读