javascript - ExtJS:存储不带参数的负载

标签 javascript extjs extjs5

我正在升级到 ExtJS 5,但无法解决此问题。我有一个函数可以管理登录后的所有内容,并在登录后使用登录时的新参数加载存储。

...
Ext.create('MyApp.store.MainStore').load({
        params: {
            auth: sessionStorage.authSessionId,
            hostname: sessionStorage.hostname
        },
        callback: function(records, operation, success) {
            //some callback
        }
})
...

但是,这会加载商店,但没有参数,这会导致服务器端出现错误。 我的商店定义:

Ext.define('MyApp.store.MainStore', {
    extend: 'Ext.data.TreeStore',
    storeId: 'MainStore',
    autoSync: false,
    autoLoad: false,

    proxy   : {
        type : 'ajax',
        url  : '/menu',
        reader: {
            type: 'json',
            rootProperty: 'children',
        },
        listeners : {
                exception : function(proxy, response, operation) {
                    //exception handling
                }
            }
    },
    fields: ['labelText','dbName','corpName','isLeaf', 'page']

});

有什么建议吗? 感谢您的帮助。

最佳答案

尝试在商店定义中声明根节点。

Ext.define('MyApp.store.MainStore', {
    extend: 'Ext.data.TreeStore',
    storeId: 'MainStore',
    autoSync: false,
    autoLoad: false,

    proxy   : {
        type : 'ajax',
        url  : '/menu',
        reader: {
            type: 'json',
            rootProperty: 'children',
        },
        listeners : {
                exception : function(proxy, response, operation) {
                    //exception handling
                }
            }
    },
    fields: ['labelText','dbName','corpName','isLeaf', 'page'],
    root: {}

});

关于javascript - ExtJS:存储不带参数的负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24839133/

相关文章:

javascript - 无法更改html中的自定义光标

javascript - 表单重置后删除 href 链接

Extjs对齐两个xtype元素

javascript - 标记字段选择 e 取消选择 : how to add and remove dinammicaly fieldcontainers to form

javascript - 从 <select> 中提取值并将它们放入数组中

javascript - JS中如何格式化字符串?

extjs - 更新或重新加载 ExtJs ComboBox 的存储

java - 无法单击 ExtJS 下拉按钮并选择列表元素 - Selenium Webdriver Java

javascript - 如何将面板添加到仪表板的特定列?

javascript - sencha extjs 5.0 应用程序无法在生产版本中运行