`
qwlong
  • 浏览: 29821 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

阅读更多
Ext.Calendar 的 phantom的问题

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.


            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'即可。
好了,说了一大堆就一个小问题,问题解决了。哈哈哈。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics