Search code examples
javascriptextjsextjs4

Reloading grid store with new url in ExtJS4


I used Simple Tasks example of Ext js 4.0 as my guide. http://docs.sencha.com/extjs/4.2.0/extjs-build/examples/simple-tasks/index.html I am now stucked with how to reload store for the grid. I set a global variable which I used in my store.

    proxy: {
    type: 'ajax',
    url: '/api/cookbookrecipe/1/1/8/8/'+ global.currentcookbook,
    extraParams: { take: 1 },
    totalProperty: 'TotalRecordCount'
}

I set the global.currentcookbook to 0. Whenever a click was caught in the tree, global.currentcookbook is changing depending on the key of the selected node in the tree.

    global.currentcookbook = 1;
    this.getTasksStore().load();

So, I used the code above to reload the grid. I can see using firebug that it is still calling the previous value of global.currentcookbook even though it was changed already.

Is it possible to change the url that the store is calling?


Solution

  • You can mod the proxy's url before load.

    var s = this.getTasksStore();
    s.proxy.url = '/api/cookbookrecipe/1/1/8/8/' + 1;
    s.load();