gpt4 book ai didi

javascript - 在网格和编辑窗口的组合框中显示条目值。 Extjs6

转载 作者:行者123 更新时间:2023-12-02 23:34:02 26 4
gpt4 key购买 nike

我有一个例子fiddle其中我使用 Ext.window.Window 来编辑网格条目。值的 id 显示在网格本身中,并在编辑窗口中为空。

对于网格中的组合框,我这样做了并且它有效

{
text : 'type',
dataIndex : 'type',
flex: 1,
renderer: function (v, p, record) {
return record.get('type');
},
},

对于表单编辑中的组合框,我添加到组合框listeners:{ render: function(combo)}

{                   
xtype: 'combobox',
store: {
type: 'type-store'
},
fieldLabel: 'Type',
displayField: 'name',
valueField: 'id',
queryMode: 'remote',
publishes: 'name',
name: 'name',
listeners:{
'render': function(combo){
console.log(combo);
combo.setValue();//How set current value
}
}

但我不明白如何正确设置当前值?

谢谢

最佳答案

首先,为了链接组合的值,您的数据 data.json 必须包含“类型”的 id,而不仅仅是描述:

{
"id": 1, "id_type":3 , "type": "Третий", "mytextfield": "Текстовое значение"
},

如果您愿意,您实际上可以使用“名称”,但您还必须将组合 valueField 更改为“名称”。

在 Controller 中,首先加载组合存储(或自动加载),然后使用窗体加载记录,而不是使用窗口的 view_model:

console.log(wind.lookup("mycombo").getStore().load());
wind.down('form').loadRecord(record);

我修改了你的 fiddle 进行这些更改

关于javascript - 在网格和编辑窗口的组合框中显示条目值。 Extjs6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56361915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com