0

在加载用户角色 [id, name] 存储后,我可以轻松创建以下表单字段,该字段动态填充角色下拉列表(用户、管理员、...)

{
    xtype: 'combobox',
    name: 'roleIds',
    queryMode: 'local',
    pinList: false,
    fieldLabel: 'Role',
    store: 'Roles',
    displayField: 'name',
    valueField: 'id',
    allowBlank: false
}

这很好用,但是将其变成无线电组所需的正确步骤是什么?如何确保在编辑记录时选择了正确的单选按钮?当表单为空并创建新用户时,如何指定默认值?

谢谢

4

1 回答 1

1

这基本上是非常相似的事情。最后你需要有这样的东西:

{
    xtype: 'radiogroup',
    fieldLabel: 'Two Columns',
    // Arrange radio buttons into two columns, distributed vertically
    columns: 2,
    vertical: true,
    items: [
        { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
        { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true},
        { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
        { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
        { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
        { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
    ]
}

所以在你从服务器接收到数据后,做一个简单的循环并创建项目数组(每个项目都是Ext.form.field.Radio然后创建一个单选组并将这个数组传入。

于 2012-05-14T21:55:08.023 回答