【问题标题】:Sencha Touch component.DataItem to dynamic listSencha Touch component.DataItem 到动态列表
【发布时间】:2014-04-08 03:55:54
【问题描述】:

好的,所以我有一个扩展Ext.dataview.component.DataItem'的视图我有这个功能

onNameButtonTap: function(button, e) {
    var record = this.getRecord();
    console.log("The tid of this record is: " + record.get('tid'));
}

我可以从这个点击中得到一个tid,我想用它来加载一个新的视图,该视图将使用这个 id 来改变代理 url 以取回不同的数据。这是视图:

Ext.define('AIN.view.Headlines.Card', {

extend: 'Ext.NavigationView',
xtype: 'headlineContainer',

config: {

    tab: {
        title: 'Headlines',
        iconCls: 'star',
        action: 'headlinesTab'
    },

    autoDestroy: false,

    items: [
        {
            xtype: 'headlines',
            store: 'Headlines',
        }
    ]
}
});

如何在我的商店中获取 url 参数以接受这样的 URL 'http://mywebsite.com/app-feeds/channels/' + tid

感谢阅读,我是新手,经过数小时的谷歌搜索后,我无法完全弄清楚。

更新,这对我有用。

var store = Ext.StoreMgr.get('Headlines');

                    store: store.setProxy({
                            type: 'jsonp',
                            url: 'http://awebsite.com/app-feeds/channels/' + tid,
                            reader: {
                                type: 'json',
                                rootProperty: 'nodes',
                                record: 'node'
                            }
                        }).load()

【问题讨论】:

    标签: extjs sencha-touch


    【解决方案1】:

    您可以通过以下方式设置Ext.data.Store 的网址:

    store.getProxy().setUrl('http://mywebsite.com/app-feeds/channels/' + tid);
    

    请注意,如果您计划在使用不同 URL 的多个区域中使用此 Store,您可能希望在设置 URL 时创建它的新实例。

    【讨论】:

    • 感谢 jprofitt 的回复,我刚刚用一些对我有用的代码更新了我的 OP。你能快速看一下,让我知道这是否是根本错误的做法吗? (因为它可能是)。谢谢
    • 我建议的唯一方法是在 Controller 而不是视图中操作代理。
    猜你喜欢
    • 2013-06-30
    • 2014-07-07
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多