我假设你tagfield
配置对象是这个样子。
var store = Ext.create('Ext.data.ArrayStore',{
fields: [
'abbr',
'state',
'description',
'country'
],
data: [
[0, 'AL', 'Alabama', 'The Heart of Dixie'],
[1, 'AK', 'Alaska', 'The Land of the Midnight Sun'],
[2, 'AZ', 'Arizona', 'The Grand Canyon State'],
[3, 'AR', 'Arkansas', 'The Natural State'],
[4, 'CA', 'California', 'The Golden State'],
[5, 'CO', 'Colorado', 'The Mountain State'],
[6, 'CT', 'Connecticut', 'The Constitution State'],
[7, 'DE', 'Delaware', 'The First State'],
[8, 'DC', 'District of Columbia', "The Nation's Capital"],
[9, 'FL', 'Florida', 'The Sunshine State'],
[10, 'GA', 'Georgia', 'The Peach State'],
[11, 'HI', 'Hawaii', 'The Aloha State'],
[12, 'ID', 'Idaho', 'Famous Potatoes']
]
});
{
xtype: 'tagfield',
fieldLabel: 'Select a state',
store: store,
reference: 'states',
displayField: 'state',
valueField: 'abbr',
filterPickList: true,
queryMode: 'local',
}
通过,如果你在标记字段选择像Alabama,Alaska,Arizona
状态这样的配置,那么你会因为在标签字段配置得到这样['AL','AK','AZ']
值已设置valueField: 'abbr'
和那些价值会到服务器进行保存。
重新加载后,如果你想选择这些值,那么你必须给出这三个值,因为它是。像
if(myField.xtype == "tagfield"){//tagfield is in lower case
myField.setValue(['AL','AK','AZ']); // myField.setValue(myValue);
}
如果你仍然想集中同一领域,如果你正在装载焦点tagfield的商店,那么你可以使用标签字段的focus
方法。
if(myField.xtype == "tagfield"){ //tagfield is in lower case
myField.focus(true,true,function(){
myField.getStore().load({
callback: function(records, operation, success) {
myField.setValue(['AL','AK','AZ']);//myField.setValue(myValue);
}
});
});
}
希望这有助于。
如果您使用tagfield作为widget,那么您可以在widgetcolumn
上使用onWidgetAttach
配置,并且您可以在其上指定功能。
请参考link。
你的意思是你正在经历与[这个错误报告]一样(https://www.sencha.com/forum/showthread.php?344610-Tagfield-with-createOnEnter-does-not-show-value-后loadRecord)? – Alexander
@亚历山大是一种类似的。当我点击焦点时,我的价值越来越高。所以我只是想,无论如何,我可以专注于一旦我加载。此外,我使用我的代码,但占位符不在IE中工作。我检查了文档,并且有一个名为'preFocus'的东西来避免使用'placeholder',但我不确定如何使用它。你能帮我怎么用'preFocus'或类似的东西 – David
我已经检查过tagfield源代码。请尝试配置选项'autoLoadOnValue:true'是否适用于您。它从错误报告的小提琴中工作。 – Alexander