【问题标题】:ExtJs. JsonStore.insert() causes exceptionExtJs。 JsonStore.insert() 导致异常
【发布时间】:2011-06-08 08:52:52
【问题描述】:

我有一个带有工具栏按钮的EditorGridPanel 来添加新记录。除了一种情况外,一切正常。当我尝试插入数据库中已经存在的记录时,服务器发回:

{"success":false,"message":"already exists","data":{}}

但是grid 创建了一个标有红色三角形的新行。如果在那之后我尝试插入一条新记录(即使它在数据库中不存在),那么在服务器端一切正常,但我在 firebug 中得到一个“未捕获的异常”。它说:

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

这是为什么呢?

编辑 我发现:

当我尝试插入新记录时,我使用 insert 方法将带有参数 data 的 post 请求发送到服务器(编码为 true,listful 为 true):

data    [{"Name":"123"}]

它从服务器获取:

{"success":true,"data":{"PositionId":"eef1d9f3-9fdf-4b87-9f6c-ef42231f4fed","Name":"123"}}

之后我尝试创建一个具有相同名称的项目:

data    [{"Name":"123"}]

所以我明白了:

{"success":false,"message":"already exists","data":{}}

来自服务器。

下次我尝试创建正确的项目时,商店会发送包含 2 个项目的数组

data    [{"Name":"1234"},{"Name":"123"}]

但服务器只创建第一个(最新的)项目并发回:

{"success":true,"data":{"PositionId":"1ff05c7f-d5fc-41cd-81f3-faabc225b2a6","Name":"1234"}}

所以这个错误可能是因为商店要求服务器创建 2 个项目,但只有一个被发回。

那么怎么处理呢?是否可以让商店不再发送失败商品的请求?

【问题讨论】:

    标签: exception extjs jsonstore


    【解决方案1】:

    尝试关闭商店中的自动保存选项。

        this.store = new Ext.data.Store({
            id: 'store'
            ,autoSave: false 
            ,autoLoad: true
            ,writer: writer,  
            ,proxy: proxy
            ,reader: reader
            scope       : this
        });
    

    更多信息参见示例http://dev.sencha.com/deploy/dev/examples/writer/writer.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-23
      • 2017-02-16
      • 2018-11-09
      • 2014-03-13
      • 2011-09-06
      • 2010-11-20
      相关资源
      最近更新 更多