簡體   English   中英

extjs combo:下次如何將用戶選擇的值設置為默認選擇的值?

[英]extjs combo:How to set user selected value as the default selected value next time?

在extjs組合框中,我有以下要求:當用戶從組合中選擇一個選項時,將其捕獲,並在下次加載頁面並初始化組合時,將值(值和displayvalue)設置為用戶的最后選擇。 我可以通過Combo.selectedIndex獲取用戶選擇的索引,但是當頁面下次加載時如何設置該索引呢?

還是有其他解決方案?

這非常非常粗糙,但是我會這樣做:

var comboStore = new Ext.data.Store({
    ...
    autoLoad: false,
    ...
});

var combo = new Ext.form.ComboBox({
    ...
    store: comboStore,
    ...
    listeners: {
       select: function() {
           ...use getValue() and save here...
       }
    }
});

comboStore.on("load",function() {
    ...load value here...
    combo.setValue(loaded value);
},this,{single: true});

comboStore.reload();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM