search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Using the DataTagFields

Asked by Wade
16 years ago.

I thought i would post my question and then DayPilot's very speedy respons and (shame) my mistake. I was putting the name of my database field into DataTagFields but not getting any results. I was under the impression that I needed to catch the DataBinding event and manually put the data into the event properties but I never saw any information appear in the event's Tag array. That was because I had the wrong fieldname in DataTagFields. Duh.

The good thing to come out of it was a nice response from Dan at DayPilot with some examples. Here is the great response I received. (One other quick note: Be sure to look at the source code that comes with the DayPilot examples. Just about every scenario covered on this forum has an answer in the samples):

<hr>

1. Using DataTagFields is simple:

Define the data source fields that you want to pass with the event in DataTagFields, e.g. DataTagFields="eventtype, background".

There are three places where you can access the information from the tag fields:

a) BeforeEventRender event handler (access it as e.Tag["eventtype"] here and use it to draw custom icons in the event, custom background colors, etc.)

b) event-related events on the client side, e.g. in EventClickJavaScript (as e.tag("eventtype"))

c) event-related events on the server side, e.g. in EventClick event handler (as e.Tag["eventtype"])

2. The DataBinding event is inherited from DataBoundControl class and DayPilot doesn't add any special functionality there. You will probably want to use BeforeEventRender event instead to modify the calendar event properties before rendering. Here is an example from Demo/Calendar/Default.aspx.cs:

protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
if (e.Value == "3")
{
//e.InnerHTML = "User actions (\"move\", \"resize\", \"click\", and 'delete') disabled for this specific event.";
e.InnerHTML = "User actions (move, resize, click, and delete) disabled for this specific event.";
e.DurationBarColor = "red";
e.EventClickEnabled = false;
e.EventMoveEnabled = false;
e.EventResizeEnabled = false;
e.EventDeleteEnabled = false;
e.ToolTip = "One\ntwo\nthree.";
}
}

It uses the ID value (stored in e.Value) but you can also use the tag fields (that will be more common):


switch (e.Tag["eventtype"]) {
case "important":
e.BackgroundColor = "red";
break;
case "deleted":
e.BackgroundColor = "gray";
break;
}

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.