Ext.Calendar bad phantom property when loading data from HttpProxy phantom=true

本文详细介绍了Ext.Calendar组件中Phantom属性设置为true的问题及解决方案。该问题导致使用RESTful方式提交数据时总是调用create而非update方法。通过将store的id属性更改为storeId并正确配置idProperty,可以有效解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ext.Calendar 的 phantom的问题

[color=red] a great component, but seem there is problem when loading data from remote httpProxy.
The record are marked as 'Phantom=true'.
The records Should be marked with a Phantom as 'false' as it is real 'record'.
The consequence is, when you drag the 'event' in the calendar the HttpProxy.api called is 'create' as the record is considered as new, because of the phantom property.
If the phantom property was false the api called would be automaticaly update.

I did not find a solution to change this property from the EventRecord.
thanks.
[/color]


this.eventStore = new Ext.data.JsonStore({
url: '/events.json',
restful: true,
root: 'events',
id: 'eventStore',
idProperty: 'id',
totalProperty: 'total',
autoLoad: true,
remoteSort: true,
fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
//************The Writer object which processes a record object for being written to the server-side database.
writer: new Ext.data.JsonWriter({
encode:true,
writeAllFields:true //write all fields, not just those that changed
}),
sortInfo: {
field: 'StartDate',
direction: 'ASC'
}
});


上面的这个问题是 有人在ExtJs官方网站提出的问题,我最近也碰到了同样的问题,正好解决了,想给这个哥们回复一下,但是 sencha不让我进行回复,所以只好在这把它写出来:

上面的问题主要是关于Ext.Calendar的问题,由于每次从store中导入数据的时候
store中的record的phantom属性都为 true,但是实际上这些信息是在数据库中存在的 应该是 phantome = false ,这样就会倒是使用restful方式进行提交的时候总是调用create方式的post 本来是要进行对记录更新的,应该使用 update的 put 。
问题基本上就是上述的问题, 主要是集中在phantom = true这个问题上。
经过我的学习与研究,发现 Extjs这堆险恶的人 对页面进行了很不好的处理,
他故意席上 id:'eventStore'进行误导你,这里的id其实就是idProperty,如果存在id这个属性会覆盖idProperty属性,所以导致idProperty。
Ext 的store不能识别id,所以就吧phantom 属性全部都只为 true.
经过我的研究改成如下方式即可

this.eventStore = new Ext.data.JsonStore({
url: '/events.json',
restful: true,
root: 'events',
storeId: 'eventStore',
idProperty: 'id',
totalProperty: 'total',
autoLoad: true,
remoteSort: true,
fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
//************The Writer object which processes a record object for being written to the server-side database.
writer: new Ext.data.JsonWriter({
encode:true,
writeAllFields:true //write all fields, not just those that changed
})
});


注意,把 id: 'eventStore' 改为 storeId: 'eventStore'即可。
好了,说了一大堆就一个小问题,问题解决了。哈哈哈。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值