具有2个相同显示值的ExtJS组合框不会更改select上的值

|| 我有一个填充有地址列表的组合框:
this.entityAddressField = new Ext.form.ComboBox(
{
    id: \'entityAddressField\',
    fieldLabel: \'Address\',
    store: entityAddressStore,
    mode: \'local\',
    width: 250,
    valueField: \'entity_address_id\',
    displayField: \'address_type\',
    tpl: new Ext.XTemplate(
        \'<tpl for=\".\"><div class=\"search-item\">\',
        \'<p><b>{address_type}</b></p>\',
        \'<p>{address_1}</p>\',
        \'<p>{address_2}</p>\',
        \'<p>{city}, {state_code} {zipcode}</p>\',
        \'</div></tpl>\'
    ),
    itemSelector: \'div.search-item\',
    hidden: true,
    triggerAction: \'all\',   
    listeners: {
        select: function(combo, record, index) {
            me.entityAddressDisplay.update(address_template.apply(record.data));
            me.entityAddressDisplay.show();
        }
    }
});
该列表在展开时显示完整的地址,但是一旦选中,组合框将仅显示displayField,这是地址类型(家庭,工作等)。 如果列出了两个“家庭”地址(相同类型但不同的地址),如果我将组合框从一个“家庭”地址更改为另一个地址,则调用:
this.entityAddressField.getValue();
将返回最初选择的项目的Entity_address_id,而不是新选择的。 我是否有规则未知,即使两个之间的valueField是唯一的,也无法阻止组合框的两个记录具有相同的displayField设置? 还是我想念其他东西?     
已邀请:
关闭组合框时,它将显示displayField值。它不受组合框上修改的tpl配置的影响。 一种解决方法是在记录定义中创建一个动态字段,将这些值连接在一起。
Ext.data.Record.create({
    {name: \'address_type\', mapping: \'address_type\'},
    ..........,
    ..........,
    ..........,
    // simple name concat
    {name: \'simple_name\', mapping: \'address_type+\" \"+obj.address_1+\" \"+obj.address_2+\"  \"+obj.city+\", \"+obj.state_code+\" \"obj.zipcode\'}
});
如果需要对可选字段(例如地址2)执行条件操作,则也可以将三元运算符等嵌套在此字段中。
Ext.data.Record.create({
        {name: \'address_type\', mapping: \'address_type\'},
        ..........,
        ..........,
        ..........,
        // simple name concat
        {name: \'simple_name\', mapping: \'address_type+\" \"+obj.address_1+\" \"+(obj.address_2 ? obj.address_2+\"  \": \"\")+obj.city+\", \"+obj.state_code+\" \"obj.zipcode\'}
    });
    
听起来您有与此类似的问题。确保商店或阅读器中装有
idProperty
。这就是商店用来唯一标识其包含的记录的工具。     

要回复问题请先登录注册