0

I'm using Extjs 4.1 MVC, I have a simple store :

Ext.define('Proj.store.GraphData', {
extend: 'Ext.data.Store',
model: 'Proj.model.GraphData',
autoLoad: false,

proxy: {
    type: "ajax",
    reader: {
        type: 'json',
        root: 'data'
    }
}});

I want to handle its update event from the controller, so this is the controller :

Ext.define('Proj.controller.RenderGraph', {
extend: 'Ext.app.Controller',
stores: ['GraphData'],
models : ['GraphData'],
init: function () {
 var me = this;
  me.getGraphDataStore().addListener('update',this.onStoreUpdate, this);
    this.control({
        ....
        })
 },
    onStoreUpdate : function () {
        alert('OKK');
   }

But when I update the store, it doesn't show anything, what am I doing wrong please?

tereško
  • 58,060
  • 25
  • 98
  • 150
salamey
  • 3,633
  • 10
  • 38
  • 71
  • A very relevant part of your code would be the one where you actually "update" the store. My feeling is that maybe you're misinterpreting when the event is supposed to fire. The way you're adding your listener should work. – rixo Nov 14 '13 at 19:37

1 Answers1

0

The first thing would be to use the full path name of your store when you are defining it in the controller

...
stores: ['Proj.store.GraphData'],
...

Also, I think listener you are looking for would be load. According to the docs, update fires when the model instance has been updated. load fires whenever the store reads data from a remote data source.

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Store-event-load

me.getGraphDataStore().addListener('load',this.onStoreUpdate, this);
lmno
  • 1,004
  • 1
  • 15
  • 27
  • *use the full path name* will not change anything. It is not necessary in this context, because the store and the controller share the same namespace. – Lorenz Meyer Nov 17 '13 at 11:21