PDA

View Full Version : Ext.Calendar bad phantom property when loading data from HttpProxy



fcoget
17 Dec 2010, 3:13 AM
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({
id: 'eventStore',
idProperty: 'id',
root: 'evts',
reader:eventReader,
writer: writer,
autoSave: true,
proxy: new Ext.data.HttpProxy({
//url: Ext.Gesbanc.Globals.URL.GesBanHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.readPlannedTestSession
api: {
create : Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.createPlannedTestSession,
read : Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.readPlannedTestSession,
update: Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.updatePlannedTestSession,
destroy: Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.deletePlannedTestSession
}
}),
fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
sortInfo: {
field: 'StartDate',
direction: 'ASC'
}
});

Condor
19 Dec 2010, 11:03 PM
This happens when you specify an invalid idProperty.

fcoget
20 Dec 2010, 2:40 AM
your are true Condore, but the id is not set in the recordset when loading data.
the id is specified but not recongnized.
I certainly miss something, but i think the problem is in the mapping logic.

here is the steps below.

first set eventStore using the Ext.calendar.EventRecord.prototype.fields.getRange() as specified in the example.

/*****************************/
var writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields: true
});

var eventReader = new Ext.data.JsonReader({
successProperty: 'success',
idProperty: 'id',
root: 'evts',
fields: Ext.calendar.EventRecord.prototype.fields.getRange()
});


this.eventStore = new Ext.data.JsonStore({
id: 'eventStore',
idProperty: 'id',
root: 'evts',
reader:eventReader,
writer: writer,
autoSave: true,
proxy: new Ext.data.HttpProxy({
//url: Ext.Gesbanc.Globals.URL.GesBanHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.readPlannedTestSession
api: {
create : Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.createPlannedTestSession,
read : Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.readPlannedTestSession,
update: Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.updatePlannedTestSession,
destroy: Ext.Gesbanc.Globals.URL.CRUDHost+Ext.Gesbanc.Globals.URL.planning+'?method=' + Ext.Gesbanc.Globals.Commands.deletePlannedTestSession
}
}),
fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
sortInfo: {
field: 'StartDate',
direction: 'ASC'
}
});
/**************************************************/


Here is the Json return by the server side when calling the read method :
as you can see the id is specified and unique.

{'success': true ,
'results': '1',
'evts':[{'id': 'D96569CA-3CBA-4BBA-A815-6D911D12D44E','cid': '10','testid': 'F96A07DE-89F8-4121-B841-9B53E9D8B087','titlte': '','start': '2010-12-21 01:30:00.0','end': '2010-12-21 06:00:00.0','ad': 'false','notes': ''},]}

AND here is the mapping for eventRecord.



Ext.calendar.EventMappings = {
id: {
name: 'Id',
mapping: 'id',
type: 'string'
},
EventId: {
name: 'EventId',
mapping: 'id',
type: 'string'
},
// calendarId porte l'info Bancid
CalendarId: {
name: 'CalendarId',
mapping: 'cid',
type: 'int'
},
TestSessionId: {
name: 'TestSessionId',
mapping: 'testid',
type: 'string'
},
Title: {
name: 'Title',
mapping: 'title',
type: 'string'
},
StartDate: {
name: 'StartDate',
mapping: 'start',
type: 'date',
dateFormat: 'c'
},
EndDate: {
name: 'EndDate',
mapping: 'end',
type: 'date',
dateFormat: 'c'
},
Location: {
name: 'Location',
mapping: 'loc',
type: 'string'
},
Notes: {
name: 'Notes',
mapping: 'notes',
type: 'string'
},
Url: {
name: 'Url',
mapping: 'url',
type: 'string'
},
IsAllDay: {
name: 'IsAllDay',
mapping: 'ad',
type: 'boolean'
},
Reminder: {
name: 'Reminder',
mapping: 'rem',
type: 'string'
},
IsNew: {
name: 'IsNew',
mapping: 'n',
type: 'boolean'
}
};



(function() {
var M = Ext.calendar.EventMappings;

Ext.calendar.EventRecord = Ext.data.Record.create([
M.Id,
M.EventId,
M.CalendarId,
M.TestSessionId,
M.Title,
M.StartDate,
M.EndDate,
M.Location,
M.Notes,
M.Url,
M.IsAllDay,
M.Reminder,
M.IsNew
]);

/**
* Reconfigures the default record definition based on the current Ext.calendar.EventMappings object
*/
Ext.calendar.EventRecord.reconfigure = function() {
Ext.calendar.EventRecord = Ext.data.Record.create([
M.Id,
M.EventId,
M.CalendarId,
M.TestSessionId,
M.Title,
M.StartDate,
M.EndDate,
M.Location,
M.Notes,
M.Url,
M.IsAllDay,
M.Reminder,
M.IsNew
]);
};
})();


Does i missed something ???
the id is set in the return data, the id value is set in the field M.EventId but when debugging in firefox the Record id as not the proper value, it as the auto-generated value.
what you said it is true, as the id is not 'recongnized' or not 'mapped' the auto generated value is used by extjs.