How to set url and root dynamically in extjs

半城伤御伤魂 提交于 2019-12-13 15:21:05

问题


Can anybody tell how to set the url and root of a store dynamically in Ext JS?

I have created a store like the one below. I need to update the root and dynamically set the url inside a controller.

Ext.define('Test.store.TestStore', {
  extend: 'Ext.data.Store',
  model: 'Test.model.TestModel',
  storeId: 'testStore',
  proxy: {
    type: 'jsonp',
    reader: {
      type: 'json',
      root: 'responseXML'
    }
  }
});

Thanks


回答1:


You can set the proxy's url later in your code this way:

store.getProxy().url = '/your/url';

After that you can just do the regular:

store.load();

or let it be triggered automatically by any binding.

Anywhere in your code you can retrieve the store through the StoreManager:

var store = Ext.data.StoreManager.lookup('myStore');


来源:https://stackoverflow.com/questions/16646944/how-to-set-url-and-root-dynamically-in-extjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!