Threaded View

  1. #1
    Sencha User
    Join Date
    May 2010
    Location
    Belgium
    Posts
    206
    Answers
    3
    Vote Rating
    1
    marxan is on a distinguished road

      0  

    Default Answered: store is null

    Answered: store is null


    Hello,

    I'm trying to generate a chart but I get the message: store is null. I'm using MVC.

    Here's my code. I don't include the model as the problem is not coming from this file.

    If anyone could help me, that will greatly appreciated.

    Code:
    Ext.define('TAB.view.GraphOptions', {    extend: 'Ext.Window',
    	alias: 'widget.graphoptions',
        layout: 'fit',
        width: 300,
        height: 150,
        //closeAction: 'hide',
        initComponent: function() {
            this.items = [
                {
                    xtype: 'form',
                    anchor: '99%',
                    items: [
                        {
                            xtype: 'radiogroup',
                            id : 'graphChoice',
                           // fieldLabel: 'Axe',
                            flex: 1,
                            columns: 2,
                            defaults: {xtype: "radio",name: "choice"},
                            items: [
                            	{ boxLabel: 'Graph', inputValue: 'N', checked:true },
               					{ boxLabel: 'Graph2', inputValue: 'S'}	
                            ]
                        },
                        {
                        	xtype: 'standardgraph'
                        }
                    ],
                    buttons: [
                     {
                        id: 'generateChart',
                        text: 'Generate',
                        scope: this,
                        handler: this.submit
                    },
                    {
                        text: 'Close',
                        scope: this,
                        handler: this.close
                    }]
                }
            ],
            
            this.callParent(arguments);
        }
    });

    Code:
    Ext.define('TAB.view.StandardGraph', {
        extend: 'Ext.chart.Chart',
    	alias: 'widget.standardgraph',
    	store: 'StandardGraphStore',
        width: 300,
        height: 150,
        axes: [
                           {
                title: 'Temperature',
                type: 'Numeric',
                position: 'left',
                fields: ['LABEISO'],
                minimum: 0,
                maximum: 100
            },
            {
                title: 'Time',
                type: 'numeric',
                position: 'bottom',
                fields: ['2008']
            }
            ],
            series : [
            {
                type: 'line',
                xField: 'LABEISO',
                yField: '2008'
            }]
        });
    Code:
    Ext.define('TAB.store.StandardGraphStore', {
        extend: 'Ext.data.Store',
        requires: 'TAB.model.StandardGraphModel',
        model: 'TAB.model.StandardGraphModel',
           proxy: {
            type: 'ajax',
            url: 'app/data/GridsLoader.cfc?method=getMetrSeries&returnformat=json',
            reader: {
                 type: 'json',
                 root: 'DATA'
            }
        }
       
    });

  2. Indeed it was the problem! Don't why I forgot to load it!

    Here's my working code.

    Thanks a lot for your help.

    Code:
    Ext.define('TAB.controller.GraphOptions', {    extend: 'Ext.app.Controller',
         model: ['StandardGraphModel'],
        stores: ['StandardGraphStore'],
        views: ['GraphOptions','StandardGraph', 'GraphContainer'],
     
        init: function () {
            var me = this;
    
    
            this.control({
            	 '#generateChart': {
                    click: this.generateChart
                }
           })
        },
        
         generateChart: function (value){
     	 var grid = Ext.getCmp('StandardGraphId');
             var store = Ext.getStore('StandardGraphStore');	
             
             store.proxy.extraParams = {
    	        	codes: Global.codeListToLoad
    	        }
    	        
             store.load();
    	 Ext.widget('graphcontainer').show();
    	}
        	
         }
    });

Thread Participants: 2