The fantastic calendar (and other great stuff) is what drew me to evaluate SmartClient. As others have noted there are a few issues that make Calendar not quite ready for prime time, notably the javascript errors you receive when try to invalidate your data source cache. This would be needed when you want to generate repeating events on the server side.
I was determined to find out how the Calendar would perform in a repeating event situation so kept hacking at it until I got pretty much error free version working which I want to offer up here. Hopefully it will work for you.
Caveats:
- It's based on 70rc2. Isomorphic are probably working on these issues and this code will likely be broken on the next release. Recommend you use it for performance evaluation purposes, only.
- If you're using SmartGWT this probably won't help you. I don't know enough about SmartGWT to say.
- All situations have not been tested. There are probably some errors still lurking.
- It's slower than plain Calendar because it's fetching from server on every event change and tab click. This subverts much of the redraw optimizations built in to Calendar. Still quite acceptable though IMO.
- I'm justing giving you the basic calendar, not the extra form fields and server code you need to implement repeating events.
- I do not claim to be following best practices in SmartClient architecture. It's a compete hack job.
I marked the customization I made with comments. Note the special datasource class that must be used with it.
This is just the stuff in the datasource relevant to Calendar. I'm using JSON so my actual datasource has some other stuff, too.
Good luck.
I was determined to find out how the Calendar would perform in a repeating event situation so kept hacking at it until I got pretty much error free version working which I want to offer up here. Hopefully it will work for you.
Caveats:
- It's based on 70rc2. Isomorphic are probably working on these issues and this code will likely be broken on the next release. Recommend you use it for performance evaluation purposes, only.
- If you're using SmartGWT this probably won't help you. I don't know enough about SmartGWT to say.
- All situations have not been tested. There are probably some errors still lurking.
- It's slower than plain Calendar because it's fetching from server on every event change and tab click. This subverts much of the redraw optimizations built in to Calendar. Still quite acceptable though IMO.
- I'm justing giving you the basic calendar, not the extra form fields and server code you need to implement repeating events.
- I do not claim to be following best practices in SmartClient architecture. It's a compete hack job.
I marked the customization I made with comments. Note the special datasource class that must be used with it.
Code:
isc.defineClass("MyCalendar", isc.Calendar);
isc.MyCalendar.addProperties({
dateChanged : function () // kg - added whole function
{
var criteria = {};
criteria.startDate = this.chosenDate;
this.setData([]); // to force delete of recurring events
this.fetchData(criteria);
},
$655 : function(_1)
{
if (_1.length > 1)
{
this.mainView = this.createAutoChild("mainView", {tabs:_1,tabSelected:function(_2, _3, _4, _5)
{
this.creator.$567 = _3.viewName;
this.creator.setDateLabel();
this.creator.refreshSelectedView(); // kg - added line
}})
}
else
{
this.mainView = _1[0].pane
}
},
closeClick : function()
{
var _1 = this.calendar;
if (_1.eventRemoveClick(this.event) == false)
{
this.$67e = true;
return
}
this.Super("closeClick", arguments);
this.calendar.removeEvent(this.event, false); // kg - modified, change boolean true to false
this.$53u = true
},
$64h : function(_1, _2, _3)
{
var _4 = [],_5 = Date.getWeekendDays(),_6 = _1.getTime(),_7 = this.getDayEnd(_1),_8 = _2.getHours() != 0 ? _2.getTime() : _7.getTime(),_9 = _6,_10 = _8,_11 = false;
var _12 = (_2.getHours() == 0 || Date.compareDates(_1, _2) < 0) ? _7 : _2;
while (!_11)
{
for (var i = 0; i < this.data.getLength(); i++)
{
var _14 = this.data.get(i);
if (_14 == "loading") // kg - added line
{ // kg - added line
_11 = true; // kg - added line
break // kg - added line
} // kg - added line
var _15 = _14[this.startDateField],_16 = _14[this.endDateField];
if (_16.getHours() == 0 || _16 < _15)
{
_16 = _7
}
if (!_15)return[];
if ((_15.getTime() >= _6 && _15.getTime() < _8 && _15.getDay() == _1.getDay()) || (_16.getTime() > _6 && _16.getTime() <= _8 && _16.getDay() == _2.getDay()) || (_15.getTime() < _6 && _16.getTime() > _8 && (_15.getDay() == _1.getDay() || _16.getDay() == _2.getDay())) && (this.showWeekends || !_5.contains(_15.getDay())))
{
_4.add(_14);
if (_3)
{
if (_15.getTime() < _9)
{
_9 = _15.getTime()
}
if (_16.getTime() > _10)
{
_10 = _16.getTime()
}
}
}
}
if (!_3 || (_9 == _6 && _10 == _8))
{
_11 = true
}
else
{
_6 = _9;
_8 = _10;
_4.clear()
}
}
return _4
}
});
Code:
isc.defineClass("CalendarServerDataSource", DataSource);
isc.CalendarServerDataSource.addProperties(
{
dropCacheOnUpdate: true,
transformResponse : function (dsResponse, dsRequest, jsonData)
{
if (dsRequest.operationType != "fetch")
{
eventCalendar.dateChanged(); // hack - this must match your calendar id
}
return dsResponse;
}
});
Comment