javascript - Extjs 模型加载出现错误 "Invalid record id returned for",但仅在从全局 Controller 触发时出现

标签 javascript rest extjs model

在我的 Extjs 应用程序中,我有一个模型:

Ext.define('Registration.model.SessionDetails', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', mapping: 'recid'}, // showing this field to show that an id field is being specified
        ...
    ],
    proxy:{
        type: 'rest',
        url: 'sessions',
        reader: {
            type: 'json',
            rootProperty: 'record'
        }
    }
});

当我通过除全局 Controller 之外的任何地方的代理加载此模型中的特定记录时,它会成功加载:

Example from javascript console

但是当我尝试从我的全局 Controller 中触发它时:

onSessionDetailNavigation: function (sessionsId){
    // where session id is 43149 passed in from my router
    var detailsWindow = Ext.widget('sessiondetails');
    var model = Registration.model.SessionDetails;

    var session = model.load(sessionsId, {
        callback: function (){
            console.log('callback fired');
        }
    });

    ...

网络调用已完成并从我的 API 返回成功:

Network call from global controller

我收到错误:

Invalid record id returned for 43149@Registration.model.SessionDetails

我认为在全局 Controller 范围内运行它不会对模型记录加载产生任何影响。我在这里缺少什么?

更新

这是尝试通过 ModelManager 获取模型的结果:

enter image description here

最佳答案

我遇到了类似的问题,在我将 ID 更改为显式设置为 int 后,它不再抛出错误。

{
    name : 'id',
    type : 'int',
    mapping : 'recid'
}

关于javascript - Extjs 模型加载出现错误 "Invalid record id returned for",但仅在从全局 Controller 触发时出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32769851/

相关文章:

javascript - Ajax - 了解文件下载是否从服务器正确发送

c# - 无法在 ItemSelector EXTJS 3 中显示所选项目

javascript - 如何检查具有类的元素是否是该类的第一个子元素

Javascript eval 结果为 "undefined function",但在 Firebug 中有效

php - 使用 JSON 输入的 CakePHP API PUT

ios - 通过 REST 响应 Office 365 事件邀请

javascript - 单击边框时,项目单击不会触发事件

javascript - Marionette 嵌套LayoutView——解析模型

javascript - HighCharts x轴和y轴标签居中对齐

r - 将 EndNote .enl 文件导入 R Dataframe