PDA

View Full Version : [CLOSED] Ext.net.EventModel: There are any way to add a property in this class?



supera
Apr 18, 2012, 6:46 PM
Hi!

I load in CalendarPanel my schedules and my tasks too... The records are storage in diferent tables in my DB.
In my webservice, I load the schedules and task in a Ext.net.EventModelCollection, with CalendarID differents for each type of record (task or schedule).
Itīs works fine...

But, the tasks have a property called 'Priority' with values between 'Urgent' and 'low priority'.
I wish renderer in event slot a icon to this priority... I know when I do this... but I donīt know a way to create a new property in EventModel (without change the source code).

Thanks for any tip.

Daniil
Apr 18, 2012, 6:51 PM
Hi,

You can extend the EventModel class.

class MyEventModel : EventModel
{

}

supera
Apr 18, 2012, 7:05 PM
Right ... and in javascript? Will be created automatically the property on the record object?


I'm override the getTemplateData and getEventBodyMarkup of view.DayBody (you pass this script to me)...
In this point I need get the property value:

Follow the overrided script:



Ext.calendar.view.DayBody.override({
getTemplateEventData: function (evt) {
var selector = this.getEventSelectorCls(evt[Ext.calendar.data.EventMappings.EventId.name]),
data = {},
M = Ext.calendar.data.EventMappings;

this.getTemplateEventBox(evt);

data._selectorCls = selector;
data._colorCls = 'ext-color-' + (evt[M.CalendarId.name] || '0') + (evt._renderAsAllDay ? '-ad' : '');
data._elId = selector + (evt._weekIndex ? '-' + evt._weekIndex : '');
data._isRecurring = evt.Recurrence && evt.Recurrence != '';
data._isReminder = evt[M.Reminder.name] && evt[M.Reminder.name] != '';
var title = evt[M.Title.name];
//data.Title = (evt[M.IsAllDay.name] ? '': Ext.Date.format(evt[M.StartDate.name], 'g:ia ')) + (!title || title.length == 0 ? '(No title)': title);
data.Title = (evt[M.IsAllDay.name] ? '' : Ext.Date.format(evt[M.StartDate.name], 'H:i ')) + (!title || title.length == 0 ? '(No title)' : title);
data.Location = evt[M.Location.name]; // added
data.Notes = evt[M.Notes.name];
data.isAlert = (((evt[M.CalendarId.name] || '0') === 11) ? true : false);
data.isTask = (((evt[M.CalendarId.name] || '0') === 12) ? true : false);
data.isBirthDate = (((evt[M.CalendarId.name] || '0') === 8) ? true : false);
return Ext.applyIf(data, evt);
},

getEventBodyMarkup: function () {
if (!this.eventBodyMarkup) {
this.eventBodyMarkup = [
'<tpl if="isAlert">',
'<i class="ext-cal-ic-alert">&nbsp;</i>',
'</tpl>',
'<tpl if="isTask">',
'<i class="ext-cal-ic-task">&nbsp;</i>',
'</tpl>',
'<tpl if="isBirthDate">',
'<i class="ext-cal-ic-birthdate">&nbsp;</i>',
'</tpl>',
'{Title}',
'<tpl if="_isReminder">',
'<i class="ext-cal-ic ext-cal-ic-rem">&nbsp;</i>',
'</tpl>',
'<br/>{Notes}', // added
'<br/>{Location}', // added
'<tpl if="_isRecurring">',
'<i class="ext-cal-ic ext-cal-ic-rcr">&nbsp;</i>',
'</tpl>',
'<tpl if="spanLeft">',
'<i class="ext-cal-spl">&nbsp;</i>',
'</tpl>',
'<tpl if="spanRight">',
'<i class="ext-cal-spr">&nbsp;</i>',
'</tpl>'
].join('');
}
return this.eventBodyMarkup;
}

});

supera
Apr 19, 2012, 2:30 PM
Hi Daniil...

I am using the url property for pass the priority code... when the event is a task, i open another window instead of the EventWindow, so, the Url property will not be shown it code to user.

You can close this thread, if you want...

thanks for your help.

Daniil
Apr 19, 2012, 2:37 PM
I think you should also add the additional fields into EventMappings.
<Ext.Net v2 sources root>\Build\Ext.Net\ux\calendar\src\data\EventMappings. js

supera
Apr 19, 2012, 4:35 PM
I'll leave it at that for now. If I need one more property, I will follow this example.

Thanks a lot for your help.

You can close this thread, if you want.