Search code examples
extjsextwebcomponents

How can I add a store to my ExtWebComponent chart after it is rendered?


How can I add a Sencha Ext JS store to my ExtWebComponent chart after it is rendered? How will it update my chart?


Solution

  • You can add your store after the web component is rendered like this. What you want to do is get a reference to the chart and then bind the store.

    Example

    _renderChart() {
      console.log("Render chart")
    
      let store = Ext.create('Ext.data.Store', {
        fields: ['id', 'g0', 'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'name'],
      });
      store.loadData(data.createData(25));
    
      let areaChartEl = this.querySelector('ext-cartesian');
      areaChartEl.ext.bindStore(store); // <<<<<<----------<<<
    }
    

    Source