Custom Calendaring with Flex
I’ve seen a number of customer inquiries of late that are focused around desired functionality that is not present in the calendar controls that are shipped with Flex. While these inquiries are all valid, the short answer is that the provided calendar controls do what they do. You could subclass them, but as controls go they are pretty complex. Rather than subclass the calendar controls to obtain the desired functionality, I propose, why not build your own calendar?
I think most developers have an aversion to trying to build their own calendar controls because they’ve tried it before with HTML/JavaScript and/or dynamic server generation, which quite frankly is a pain. In Flex however you have a consistent runtime and precision control over the placement and integration of ever last facet of the display. Where you might otherwise spend time trying to figure out how to subclass the existing calendar controls, building your own can bring many benefits with it such as specificity, performance and maintainability.
When you build your own calendar, you control how it behaves based on your specific requirements. By contrast the calendar controls included with Flex are trying to reflect every last potential combination of styling and selection that a customer might eventually want to make. When you forego that abstraction you stand to gain performance. Finally, since you wrote it, you know how to change it, which increases code reuse and maintainability.
I’m not trying to suggest that you reinvent every control that comes with Flex, but in the case of the calendar control, because most customers have very specific needs, it makes sense to give it a go. In the end, you’ll likely spend less time building your own (thanks to the power of Flex) than trying to subclass the existing calendar controls.
I’ve attached the source for a custom calendar to this blog entry. The calendar control I’ve created is based off a popular RIA demo, and a great RIA success story. It is generic enough and well-commented enough that hopefully you’ll be inclined to get under the covers and make modifications, or just explore to establish the foundations of your own calendar control. The data for this control is also hooked to an included Java object which is being accessed as a remote service. This will hopefully reflect a more common enterprise requirement.
I have a significantly scaled down version that I can posts for anybody who’d like a more straight-forward introduction to building your own calendar with Flex. Just let me know. Following is a screenshot with a few days selected.
