Extjs抛出异常“实现被无效的远程数据调用”成功创作纪录 [英] Extjs throws exception "realize was called with invalid remote-data" on successful creation of record

查看:202
本文介绍了Extjs抛出异常“实现被无效的远程数据调用”成功创作纪录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单轨应用程序中使用extj。我正在使用JsonStore将数据保留回我的控制器。我已经阅读,更新和删除工作正常。但我似乎无法弄清楚如何格式化我的回复创建。目前,Firebug给了我以下错误:


未捕获的异常:
Ext.data.DataReader:#realize是
用无效的远程数据调用。
请参阅
的文档DataReader#实现并查看
DataReader配置。


我对于WTF这个错误的意思就是这样。任何人都有指针?

  var proxy = new Ext.data.HttpProxy({
api:{
read:'../foo/bar.rnr',
create:'../foo/CreateBar.rnr',
update:'../foo/UpdateBar.rnr',
destroy:'../foo/DeleteBar.rnr'
}
});

var writer = new Ext.data.JsonWriter({
encode:true,
writeAllFields:true,
listful:true,
destroyRecord:function (rec){
return this.toHash(rec);
}
});


var store = new Ext.data.JsonStore({
autoLoad:true,
autoSave:false,
url:'../foo /bar.rnr',
method:'get',
baseParams:{Id:pageParameters.Id},
proxy:proxy,
writer:writer,
id:'id',
fields:[
{name:'Id',type:'int'},
{name:'Name',type:'string'},
{name:'Note',键入:'string',defaultValue:null}

]
});

我当前的回复看起来像这样,但这是经过大量的试错,所以它是prol prol ho。。。。。。>:::::::::}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}


解决方案

您需要在返回的json中返回记录



转到我的书Ext JS in Action中的以下示例,显示如何使用数据写入器进行粗暴动作。



http://extjsinaction.com/examples/chapter08/usingWriterWithHttpProxy.html



右键单击以插入新记录。从firebug观察Ajax req,你会看到它的行动。


I am using extjs in a monorail application. I am using a JsonStore to persist data back to my controller. I have read, update and delete working properly. But I cannot seem to figure out how to format my response back on creates. Currently, Firebug gives me the following error:

uncaught exception: Ext.data.DataReader: #realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.

I am flummoxed about WTF this error means. Anyone have pointers? Relevant bits of code below:

 var proxy = new Ext.data.HttpProxy({
        api: {
            read: '../foo/bar.rnr',
            create: '../foo/CreateBar.rnr',
            update: '../foo/UpdateBar.rnr',
            destroy: '../foo/DeleteBar.rnr'
        }
    });

    var writer = new Ext.data.JsonWriter({
        encode: true,
        writeAllFields: true,
        listful: true,
        destroyRecord: function(rec) {
            return this.toHash(rec);
        }
    });


    var store = new Ext.data.JsonStore({
        autoLoad: true,
        autoSave: false,
        url: '../foo/bar.rnr',
        method: 'get',
        baseParams: { Id: pageParameters.Id },
        proxy: proxy,
        writer: writer,
        id: 'Id',
        fields: [
            { name: 'Id', type: 'int' },
            { name: 'Name', type: 'string' },
            { name: 'Note', type: 'string', defaultValue: null }

        ]
    });

My current response looks like this, but this is after a lot of trial and error, so it is prolly hosed.

{"success":true,"message":"OK!","undefined":[]}

解决方案

You'll need to return records in the returning json object.

Go to the following example from My book, Ext JS in Action, that shows how to use data writer for crud actions.

http://extjsinaction.com/examples/chapter08/usingWriterWithHttpProxy.html

Right click to insert a new record. Observe the Ajax req's from firebug and you'll see it in action.

这篇关于Extjs抛出异常“实现被无效的远程数据调用”成功创作纪录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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