How to use the same store with a different url in extjs

I work in extjs. I have a store like -

 Ext.define('Balaee.store.qb.QbqnsStore',{
            extend: 'Ext.data.Store',
            model: 'Balaee.model.qb.QbqnsModel',
            autoLoad: true,

            proxy:
            {
                type:'ajax',
                api:
                {
        read:index.php/QuestionBank/qbpaper/createpaper',

        },
                reader:
                {type:'json',
                    //root:'polls',},
                writer:
                {type:'json',
                    root:'data',
                }}});

Thus, the proxy read property is set above Url. Now I want to use the same store for some other view, but with a different read url. Also how to dynamically change the storage url? I tried, when I click the mouse I want to read data from url- /index.php/QuestionBank/qbpaper/Reviewquestionpaper111

So the button click function I wrote is

review:function()
    {
        //alert("hello");

        var QbqnsStore=this.getStore('qb.QbqnsStore');
        proxy=QbqnsStore.getProxy();
        Ext.apply(proxy.api,{
            read:'http://127.0.0.1/s_balaee/Balaee/index.php/QuestionBank/qbpaper/Reviewquestionpaper',

        });

I create a variable for this store and provide the new required URL. Bt its not working. So, how to use the same store for different views with a different URL in the read property.

+5
source share
4

:

QbqnsStore.proxy.url =  'new url';

, url.be URL- :

QbqnsStore.reload();
+3

:

 var QbqnsStore=this.getStore('qb.QbqnsStore').load({url:'newUrl'});
+2

You can simply change the read property of the proxy object :

  var store = this.getStore('qb.QbqnsStore');
  proxy = store.getProxy();
  proxy.api.read = 'http://127.0.0.1/myNewUrl';

And then call the methods store.sync()or store.load().

0
source

store.proxy.api.read = 'new url';

0
source

All Articles