Dav*_*vid 7 javascript extjs extjs6-classic
我使用tagfield作为widget列.我从下拉列表中选择几个值然后保存它.当我打开时,我希望我的选定值应该出现在tagfield中.只有在tagfield聚焦之后才会出现.
我在这里尝试的是,我的代码:
var SValue = XML.getAttribute('value');
if(filterType.xtype == "tagfield"){
filterType.setValue(SValue); // This is not working
filterField.inputEl.set({'placeholder':SValue}); // This is working but not correct way to do.
}
Run Code Online (Sandbox Code Playgroud)
我使用占位符它有点显示值,但这不正确我想要的.任何人都可以建议我在这里做什么.如果它自动聚焦,那么也有机会工作.
注意:换句话说,它喜欢如何通过从XML读取特定属性来加载或设置值到tagfield.
我能想到的 TagField 在设置时不显示值的唯一原因tagField.setValue(value)是该值不存在于商店中。
所以你有几个选择:
1 - 在设置值之前加载存储:
var SValue = XML.getAttribute('value'),
store;
if (filterType.getXType() === "tagfield") {
store = filterType.getStore();
if (store) {
store.load({
callback: function() {
filterType.setValue(SValue);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
2 - 创建 tagField 并选择不在商店中的值,因此forceSelection: false在 tagField 配置中进行设置。