我假設你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