JsonStore加载记录并将它们标记为幻像

Val*_*rio 2 extjs store jsonstore extjs3

我的JsonStore如此定义:

var data_json = new Ext.data.JsonStore({
    url: '/Game/json_index',
    autoLoad: true,
    id: 'data_json',
    idProperty: 'id',
    fields: [ {name: 'id', type: 'int'}, 'name', {name:'add_date', type:'date', dateFormat: 'M$'}, 'price', 'kind', 'metacritic'],
    listeners: { 'load': function(storename, records, options){
    console.dir(this);
    }},
    writer: new Ext.data.JsonWriter()
})
Run Code Online (Sandbox Code Playgroud)

它收到的JSON的DUMP是这样的:

[
{"id":1,"name":"Guild Wars 2","add_date":"\/Date(1346104800000)\/","price":24.99,"kind":"MMO","metacritic":93},
{"id":2,"name":"Dark Souls: Prepare to Die Edition","add_date":"\/Date(1345759200000)\/","price":45.00,"kind":"actionrpg","metacritic":87},
{"id":3,"name":"Orcs Must Die! 2","add_date":"\/Date(1343599200000)\/","price":15.00,"kind":"action","metacritic":83}
]
Run Code Online (Sandbox Code Playgroud)

JSON被正确解码,商店里满是我的记录,但要注意......可怕的事情发生了!

可怕的事情的屏幕截图

所有记录都标记为phantom = true,这不能让我正确使用ExtJS 3.4.x store.save()功能

我在google上彻底搜索了这个问题,并且(我认为)它与JsonReader没有将记录id与我传递的'id'字段相关联的事实联系起来.我甚至指定了idProperty:'id'.

帮忙吗?我变得绝望,阅读关于创造记录的极端来源是纯粹的痛苦.

chi*_*fet 5

尝试删除:

id: 'data_json'
Run Code Online (Sandbox Code Playgroud)

从你的商店.JsonStore的所有配置选项都会传递到自动创建的JsonReader中,而这似乎正在搞砸它.

  • 这解决了!'id'它在商店被弃用; 使用storeId它是处理它的正确方法 (2认同)