|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Building an Outlook-like calendar component for ASP.NETThe story is simple and you might have already heard it: I needed a component and because I wasn't able to find a good one I decided to write it. I was thinking like this: It would take me two hours to find it, another two hours to understand it and another two hours to customize it. Six hours. In six hours, I should be able to write a simple component by myself. My project specification was simple. Features
Features that are not supported
In short, no AJAX at the moment. What I need is to show the events arranged and catch the most important events (clicking the event and clicking the free space). Problem #1: Algorithm for arranging concurrent eventsThis didn't take too long. After the first hour I had the draft:
Let's demonstrate it visually:
The algorithm can be described in the following steps:
Now, we can calculate the position of each
Problem #2: Positioning the events using CSSTo show the calendar we need to draw a table with the hour numbers and yellow free cells and then draw another layer on top of the calendar that contains the events. The other "layer" can be created by setting the cascading style: position: absolute;
top: 20px;
left: 20px;
The position is defined by the "top" and "left" coordinates. These are related to the upper left corner of the document or to the upper left corner of the containing element that has the position defined (if any). Problem #3: Box size behavior in Firefox/Internet ExplorerThe biggest problem while calculating the positions was a major difference between Firefox and Internet Explorer:
To achieve the same behavior in IE and FF, I had to nest several <div onselectstart="return false;"
onclick="event.cancelBubble=true;alert('Event ID: 4');"
onmouseover="this.firstChild.style.backgroundColor='#DCDCDC';
event.cancelBubble=true;"
onmouseout="this.firstChild.style.backgroundColor='white';
event.cancelBubble=true;"
style="-moz-user-select:none;-khtml-user-select:none;
user-select:none;cursor:pointer;cursor:hand;
position:absolute;font-family:Tahoma;font-size:8pt;
white-space:no-wrap;left:0%;top:1;width:100%;height:40;
background-color:gray;">
<div title="Breakfest (8:00 AM - 9:00 AM)"
style="margin-top:1px;display:block;height:38;
background-color:white;border-left:1px solid gray;
border-right:1px solid gray;overflow:hidden;">
<div style="float:left;width:5px;height:100%;
background-color:blue;">
</div>
<div style="float:left;width:2px;height:100%;"></div>
<div style="padding:2px;">Breakfest (8:00 AM - 9:00 AM)
</div>
</div>
</div>
Problem #4: Firefox treated as a low-level browserIt is a known problem. The symptoms were that the There are two possible solutions:
The first option was not possible because of the additional configuration required so I had to create several helper classes and write it directly as whole strings. The final resultFinally, it took me a few days instead of a few hours but now you can share the result with me:
UpdatesPlease visit the DayPilot site for the updates. History
|
||||||||||||||||||||||