【问题标题】:EXT-JS ui not updating after adding data to store将数据添加到存储后,EXT-JS ui 未更新
【发布时间】:2017-03-03 16:31:11
【问题描述】:

我正在尝试在创建后将项目添加到组合框,但添加了存储数据但未在 UI 中更新。

Ext.onReady(function () {

    Ext.create('Ext.data.Store', {
        storeId: 'simpsonsStore',
        autoLoad: true,
        fields: ["name", "value"],


        listeners: {
            load: function(store, rec) {
                store.add([["val1",1],["val2",2]]);
            }
        }
    });

    Ext.create('Ext.form.field.ComboBox', {
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        valueField: "value",
        displayField: "name",
        renderTo: Ext.getBody()
    });

    var s2 = Ext.getStore('simpsonsStore');
    s2.loadData([["val3",3]],true);
});

首先添加 Val1 和 Val2。渲染后我想添加 val3

【问题讨论】:

标签: javascript extjs extjs3


【解决方案1】:

我认为autoload=true 假设没有数据并且正在鞭打s2.loadData(),它首先被执行。 这在最新版本中不会发生。

在不自动加载的情况下手动调用store.load() 可以解决问题。还有combobox需要queryMode='local'

类似的工作小提琴:http://jsfiddle.net/tonymayoral/8jzfo7zj/1/

var st=Ext.create('Ext.data.Store', {
        storeId: 'simpsonsStore',
        //autoLoad: true,
        fields: ["name", "value"],

        listeners: {
            load: function(store, rec) {
                store.add([["val1",1],["val2",2]]);
            }
        }
    });

    st.load(); 

    Ext.create('Ext.form.field.ComboBox', {
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        valueField: "value",
        displayField: "name",
        queryMode:'local', //needs to be local
        renderTo: Ext.getBody()
    });

    var s2 = Ext.getStore('simpsonsStore');
    s2.loadData([["val3",3]],true)

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多