【问题标题】:Update Chart when add/remove records Ext JS添加/删除记录时更新图表 Ext JS
【发布时间】:2019-09-27 03:52:08
【问题描述】:

ExtJS 7.0 现代 图表的记录在编辑网格单元格时会发生变化,但在我添加/删除行时不会发生变化。 我已经在控制器页面中尝试了 store.sync() 、 store.update() 、 .load() ,但这些接缝都没有工作。 这是我试图放置逻辑的块。 (除与图表同步外,一切正常)

showChart: function(btn){
    var chart = Ext.create({
        xtype: 'kleachart'

    }) ;
    chart.show() ;
    console.log("CHART",chart) ;
},

https://fiddle.sencha.com/#view/editor&fiddle/2vh0

提前谢谢!

【问题讨论】:

    标签: javascript extjs


    【解决方案1】:

    问题是商店的多个实例。 当您创建 kleachart 的新实例(也有 viewModel 实例)时 - 将创建新的 store 实例。

    showChart: function (btn) {
        var store = this.getView().getStore();
        //model = store.getRecordModel();
        console.log("STORE", store);
    
        // store = this.getView().getStore().getData();
        // here your logic (see at "reloadStore")
        var chart = Ext.create({
            xtype: 'kleachart',
            title: 'Hello',
            // handler: function (btn) {
            //    store.sync();
            // }
    
        });
    
        chart.show();
    
        console.log("CHART", chart);
    
    }
    

    你可以这样引用老店:

    showChart: function (btn) {
        var store = this.getView().getStore(),
            parentViewModel = this.getViewModel();
        var chart = Ext.create({
            xtype: 'kleachart',
            title: 'Hello',
            viewModel: new Ext.app.ViewModel({
                stores: {
                    klea: store
                }
             })
        });
        chart.show();
    },
    

    检查更新Fiddle

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 2012-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多