在ExtJs 4中,商店中的新记录在同步到服务器之前获得了0
作为id。在ExtJs 6中,标识为'Mb.model.images.Image-1'
。
Ext.define('Mb.model.images.Image', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'code', type: 'string'},
{name: 'filename', type: 'string'},
{name: 'path', type: 'string'}
]
})
是否有可能在ExtJs 6中获得旧行为?
我查看了identifier: 'sequential'
,但这会在客户端分配一个自动增量ID,它将与服务器端分配的ID冲突。
答案 0 :(得分:2)
不,不是。会话周围 ExtJS 5 的变化要求所有模型都具有唯一的ID
。
您可以使用phantom
属性查看模型是否从未保存过。
此外,Proxy类知道模型是否是幻像,并将根据幻像标志的状态(Create operations vs Update operations)发出不同的调用。
任何服务器端分配的ID
都会覆盖刚刚保存的模型的ID
。