如何在extjs中动态设置url和root [英] How to set url and root dynamically in extjs

查看:126
本文介绍了如何在extjs中动态设置url和root的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉如何在Ext JS中动态设置商店的url和根吗?

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

我创建了一个类似于以下商店的商店.我需要更新根目录并在控制器内部动态设置URL.

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'
    }
  }
});

谢谢

推荐答案

稍后您可以通过以下方式在代码中设置代理的网址:

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.

您可以在代码中的任何位置通过StoreManager检索商店:

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

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

这篇关于如何在extjs中动态设置url和root的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆