Extjs 在成功创建记录时抛出异常“realize was called with invalid remote-data”
Posted
技术标签:
【中文标题】Extjs 在成功创建记录时抛出异常“realize was called with invalid remote-data”【英文标题】:Extjs throws exception "realize was called with invalid remote-data" on successful creation of record 【发布时间】:2010-03-05 18:50:33 【问题描述】:我在单轨应用程序中使用 extjs。我正在使用 JsonStore 将数据保存回我的控制器。我已阅读、更新和删除工作正常。但我似乎无法弄清楚如何在创建时重新格式化我的回复。目前,Firebug 给我以下错误:
未捕获的异常: Ext.data.DataReader: #realize 是 使用无效的远程数据调用。 请参阅文档 DataReader#实现并查看您的 数据读取器配置。
我对这个错误的含义感到困惑。有人有指点吗?相关代码如下:
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
]
);
我目前的反应是这样的,但这是经过大量试验和错误之后,所以它被大量冲洗了。
"success":true,"message":"OK!","undefined":[]
【问题讨论】:
【参考方案1】:您需要在返回的 json 对象中返回记录。
从我的书 Ext JS in Action 中转到以下示例,该示例展示了如何使用数据编写器进行 crud 操作。
http://extjsinaction.com/examples/chapter08/usingWriterWithHttpProxy.html
右击插入一条新记录。观察来自 firebug 的 Ajax req,你会看到它在起作用。
【讨论】:
以上是关于Extjs 在成功创建记录时抛出异常“realize was called with invalid remote-data”的主要内容,如果未能解决你的问题,请参考以下文章
removeItem(at: ) 成功删除目标文件时抛出异常
SqlDataReader 在尝试将数据加载到 DataGrid WPF 时抛出异常