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

Issue in EventClickJavaScript

Asked by Anonymous
16 years ago.
Event Render
I got some issue at EventClickJavaScript.
The code below assigning the EventClickJavaScript property based e.value.
Example:
A person got Ticket and Opertunity in same day.
Case 1
Time URL type
10.00am Ticket
11.00am Opertunity
15.20pm Ticket
The above 3 event if I click its redirecting URL Ticket page ("document.location='wfTicket.aspx?id=' + e.value()") which is last type. But its not redirecting Opertunity page (document.location= Opertunity.aspx?ID=' + e.value()").

Case 2
Time URL type
10.00am Opertunity
11.00am Ticket
15.20pm Opertunity
The above 3 event if I click its redirecting URL Opertunity page (document.location= Opertunity.aspx?ID=' + e.value()") which is last type. But its not redirecting Ticket page ("document.location='wfTicket.aspx?id=' + e.value()").

I assume its over Overwriting with latest URL.

The following items working fine:
Tooltips shows differently like ticket and opertunity in same day
Leftbar color changing
InnerHTML
Please me to fix the issue. We need to lunch the project very soon. Please refer the code below:




// Loading Each events with address, name, and event type when render each events.
private void DPC_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
DayPilotCalendar d = sender as DayPilotCalendar;

string strVal = "";
if (null != d)
{
DataSet dsEvent = (DataSet)d.DataSource;
DataRow drEvent = dsEvent.Tables[0].Rows.Find(e.Value);
if (drEvent != null)
{
strVal = drEvent["id"].ToString() + ", " +
drEvent["name"].ToString() + ", ";
if (drEvent["a1"].ToString().Length > 0)
strVal = strVal + drEvent["a1"].ToString() + ", ";
if (drEvent["a2"].ToString().Length > 0)
strVal = strVal + drEvent["a2"].ToString() + ".";
}

if (e.Value.Substring(0, 1).ToLower() == "t")
{
d.EventClickJavaScript = "document.location='wfTicket.aspx?id=' + e.value()";
e.ToolTip = "Ticket";
e.LeftBarColor = "blue";
e.InnerHTML = strVal;
}
else
{
e.LeftBarColor = "red";
e.ToolTip = "Opertunity";
e.InnerHTML = strVal;
d.EventClickJavaScript = "document.location= Opertunity.aspx?ID=' + e.value()";
}
}
} //DPC_BeforeEventRender

Comment posted by Dan Letecky
16 years ago.
There can be only a single JavaScript handler and that will be used to handle all events. You are right that the last one will overwrite all previous changes.

You should move the logic into a client-side handler. One of the possible solutions:

1) Store event type into Tag (by using DataTagField property).
2) Create a new JavaScript event handler:

<script type="text/javascript">
function clickHandler(e) {
if (e.tag() == 'Opertunity') {
document.location = 'Opertunity.aspx?id=' + e.value();
}
else {
document.location = 'Ticket.aspx?id=' + e.value();
}
}
</script>
3. Set EventClickJavaScript to call this function (it can be done in the ASPX declaration):
EventClickJavaScript = "clickHandler(e);"
See also a similar question here: http://forums.daypilot.org/Topic.aspx/97/event_click_javascrip_dyanmically
Comment posted by Anonymous
16 years ago.
thanks
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.