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

DayPilot

Asked by poupoune
11 years ago.

HI,
I need to click on a DayPilot Cell programmatically.
dps1.cellClick(dps1.events[0]); //don't work

Thanks

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

I assume you mean the events (coming from DataSource), not the background cells (the matrix).

To fire the client-side EventClick event, call this:

dps1.onEventClick(e);

e is the DayPilot.Event object. See also:

http://api.daypilot.org/daypilot-event-class/

If you want to fire the server-side EventClick handler use this:

dps1.eventClickCallBack(e);

If you want to find the event object by id use this:

var e = dps1.events.find(id);

http://api.daypilot.org/daypilot-scheduler-events-find/

For recurring events:

var e = dps1.events.findRecurrent(masterId, start);

http://api.daypilot.org/daypilot-scheduler-events-findrecurrent/

Comment posted by poupoune
11 years ago.

Thanks, I'm a step further now :
dps1.eventClickCallBack(dps1.events[0]); //opens the contextMenu

Now I'd like to simulate the click on the firs option of this contextmenu.

Thanks so much, I'm searching since hours ....

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

You will have to look up the <a> element inside the menu and fire onclick() on it. The main menu <div> can be accessed using menu.div (for DayPilotMenu.ClientObjectName="menu").

Comment posted by poupoune
11 years ago.

Here is what I would like to do :
Every Daypilot.event object has a contextMenu, with only 1 option who opens a new page.
I would like to open this page programmaticaly.

My events : dps1.events[i], with i from 0 to 8
The onclick function : <a onclick="DayPilotMenu.click(this, 'OpenNewPage', 'PostBack'); return false;" ....

Is that possible ?

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

You can invoke the server-side EventMenuClick event directly:

dps1.eventMenuClickPostBack(e, "OpenNewPage");
Comment posted by poupoune
11 years ago.

I tried dps1.eventMenuClickPostBack(dps1.events[0], "OpenNewPage");
A new page opens but with an error of the server.

Does this command perform the click of the first option in the ContextMenu of the event ?

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

This method is called when the user clicks on the following menu item:

<DayPilot:MenuItem Action="PostBack" Command="OpenNewPage" Text="Open New Page" />
Comment posted by poupoune
11 years ago.

I Think I know where is the problem :
<a onclick="DayPilotMenu.click(this, 'OpenNewPage', 'PostBack'); return false;" ....

"this" refers to the Window, and seems to send the mouse position which is used in the calle dfunction.
Would it be possible to add those information ?

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

This looks like it comes from very old version of DayPilot:

<a onclick="DayPilotMenu.click(this, 'OpenNewPage', 'PostBack'); return false;" ....

Since about 6.1 (http://www.daypilot.org/daypilot-pro-6-1.html) the menu uses a new logic and API and this is no longer supported.

But obviously "this" represents the <a> element so you need to pass it to the function as the first parameter.

Comment posted by poupoune
11 years ago.

OK...

But I've no idea how to pass the <a> element, there is no ID, no name, ....
here it is :

<a style="padding:20px 20px 20px 10px;display:block;cursor:pointer;color:#282828;text-decoration:none;white-space:nowrap;" href="#" onclick="DayPilotMenu.click(this, 'OpenNewPage', 'PostBack'); return false;">Send Data</a>

So near to find ....

Comment posted by poupoune
11 years ago.

Here again ;-)

document.getElementById('mp_Content_DayPilotMenuLight').children[1] refers to the <a>

But

dps1.eventMenuClickPostBack(document.getElementById('mp_Content_DayPilotMenuLight').children[1],dps1.events[0], 'OpenNewPage');

sends an error too.

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

You don't need the element for .eventMenuClickPostBack(). It should be used like this:

dps1.eventMenuClickPostBack(e, "OpenNewPage");

If you ensure that e is DayPilot.Event it will work fine, at least in the recent releases.

Comment posted by poupoune
11 years ago.

The release must be the problem, because if I right click and chose the option manually with a mouse click, the desired page is loaded.
And with dps1.eventMenuClickPostBack(dps1.events[0], "OpenNewPage"); there is an error page.
It seems I have to wait the update of the release.
Anyway, Thanks for your help, I've learned so much tooday

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

And what version of DayPilot are you using?

With the latest release, you can't use dps1.events[0] because it doesn't hold DayPilot.Event object.

You need to find it using events.find() as I suggested above.

You can also create it from the internal list like this:

var first = new DayPilot.Event(dps1.events.list[0]);

Comment posted by poupoune
11 years ago.

/* DayPilotPro: 5.8.1956.0 */

and dps1.events[0] works great

Comment posted by poupoune
11 years ago.

I think you are right when you think I shouldn't use dps1.events[0]

The console log of the event "e" (the one I need) is :
Object { root={...}, data={...}, value=function(), more...}
where root is Object { id="mp_Content_DayPilotScheduler1", autoRefreshEnabled=false, autoRefreshInterval=60, more...} and where data is exactly the Object below:

The console log of the my "dps1.events[0]" (the one I think it is "e")
Object { InnerHTML="RV with John D", Start=dimanche 19 mai 2013 08:10:00, End=dimanche 19 mai 2013 16:10:00, more...}

So, I tried :

  • dps1.events.first() which gives me the same as dps1.events[0]"
  • dps1.events.list[0] is not available in this version of DayPilot
  • dps1.events.find('John') throws a TypeError: iterator.call is not a function

Any ideas ?

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

The best solution would be to upgrade to the latest version. In 7.3 you can use the examples above; you can also create the object manually using DayPilot.Event constructor:

var e = new DayPilot.Event({ ... }).

See here: http://api.daypilot.org/daypilot-event-constructor/

The 5.8 version is not supported anymore.

You can try to create the event object manually - for the event handler it is only necessary that it has .toJSON() method that returns a simplified object ready for serialization - take your existing "e" object and call e.toJSON() to see what is expected.

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