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

ShiftScheduling tutorial

Asked by Andrea
8 years ago.

In the shiftscheduling tutorial where is the EventClickJavaScript="eventClick(e);" function? I don't see in the default.aspx. I found in event_handling.js but if I put a stop mark in the debug the program doesn't stop there when I click to create a new event.
Can you explain better this concept? Is there any article about using this type ofevent Handling? thank you

Answer posted by Dan Letecky [DayPilot]
8 years ago.

It works like this:

1. When you use EventClickHandling="JavaScript" the Scheduler will fire the JavaScript code specified using EventClikJavaScript property.

2. It will pass "e" object to the JavaScript code - it's the DayPilot.Event object (http://api.daypilot.org/daypilot-event-class/) that represents the event. You can use it to read the event properties, such as id:

var id = e.id();

3. The shift scheduling tutorial (http://code.daypilot.org/34377/shift-scheduling-tutorial-asp-net-sql-server-c-vb-net) uses the eventClick() method to open a modal dialog with event details. It is defined in event_handling.js:

function eventClick(e) {
    var modal = dialog();
    if (e.recurrent()) {
        modal.showUrl("Edit.aspx?id=" + e.recurrentMasterId());
    }
    else {
        modal.showUrl("Edit.aspx?id=" + e.value());
    }
}

function dialog() {
    var modal = new DayPilot.Modal();
    modal.top = 60;
    modal.width = 400;
    modal.height = 450;
    modal.opacity = 70;
    modal.border = "10px solid #d0d0d0";
    modal.closed = function () {
        if (this.result == "OK") {
            dp.commandCallBack('refresh');
        }
        dp.clearSelection();
    };
    return modal;
}

I have tested the tutorial code and it seems to work fine - try adding a console.log() call to the method:

function eventClick(e) {
  console.log("opening event details for event: " + e.id());
}

4. It uses DayPilot.Modal helper to open the target page (Edit.aspx) in a modal dialog. You can find more details about the DayPilot.Modal helper here:

http://code.daypilot.org/81367/daypilot-modal

Answer posted by Andrea
8 years ago.

Hello, I added like you suggested in the eventClick() method but the program doesn't stop there when I create a new event. This is the code:

function eventClick(e) {
console.log("opening event details for event: " + e.id());
var modal = dialog();
if (e.recurrent()) {
modal.showUrl("Edit.aspx?id=" + e.recurrentMasterId());
}
else {
modal.showUrl("Edit.aspx?id=" + e.value());
}
}

I mean the event_handling.js inside the folder "Scripts - DayPilot".

When I create a new event the debug stops in the method function timeRangeSelected(start, end, location, person).
Why? Is it a mistake by me?
Thanks

Comment posted by Andrea
8 years ago.

...and, strange, in the "dynamic" event_handling.js showed in debug mode there isn't the line "console.log("opening event details for event: " + e.id());" that I wrote in the eventClick(e) method before running the web application. Maybe I don't have enough information about it? I don't understand...thank you

Comment posted by Andrea
8 years ago.

I veryfied...When a user select a new event it fires the method timeRangeSelected, not the method eventClick(e). The method eventClick(e) works only to edit the event. Is it correct? But the question before remains... ("...and, strange, in the "dynamic" event_handling.js showed in debug mode there isn't the line "console.log("opening event details for event: " + e.id());" that I wrote in the eventClick(e) method before running the web application. Maybe I don't have enough information about it? I don't understand...thank you")
I'm waiting fotr your gently answer.
Thank you

Comment posted by Andrea
8 years ago.

Can someone answer me? thanks

Comment posted by Dan Letecky [DayPilot]
8 years ago.

Andrea,

Yes, it works like this:

1. TimeRangeSelected is fired when you click a grid cell.
2. EventClick is fired when you click an event.

I did a few tests and all seems to be working fine.

It seems that in your case the problem might be that the browser is using a cached version of event_handling.js. It might also not handle the breakpoint correctly.

You can try moving the JavaScript event handlers to the main page, into a special <script> block. Let me know if it didn't help.

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