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

Set dps.startDate and dps.days via javascript

Asked by Simon
9 years ago.

How do I change dps.startDate and dps.days after the scheduler has been rendered?

I've tried calling dps.show() or dps.update() after setting the properties, but nothing happens.

So how do I re-render the scheduler after startDate and days has been set?

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

You should call .update() after changing startDate or days. This is an example from the the navigator integration demo:

http://javascript.daypilot.org/demo/scheduler/navigator.html

See onTimeRangeSelected event:

    var nav = new DayPilot.Navigator("nav");
    nav.cssClassPrefix = "navigator_8";
    nav.showMonths = 3;
    nav.selectMode = "month";
    nav.onTimeRangeSelected = function(args) {
        dp.startDate = args.start;
        dp.days = args.days;
        dp.update();
    };
    nav.init();

See also:
http://doc.daypilot.org/scheduler/navigator/

Just remember that if you are using a manual timeline (.scale = "Manual") you need to rebuild the timeline array rather than changing .startDate and .days.

See also:
http://doc.daypilot.org/scheduler/timeline/

Comment posted by Simon
9 years ago.

Instead of changing startDate with a navigator I'm using a jquery datepicker and is therefore setting it like this:

dps.startDate = new DayPilot.Date($intStart.datepicker("getDate"));

Calling dps.update() after doing so doesn't do anything.

This is how the scheduler is initialized in my view file:

@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig()
{
BackendUrl = Url.Content("~/Scheduler/Backend"),
CssOnly = true,
CssClassPrefix = "mw",
TimeRangeSelectedHandling = TimeRangeSelectedHandlingType.JavaScript,
TimeRangeSelectedJavaScript = "pm.rangeSelected(start, end, resource)",
EventClickHandling = EventClickHandlingType.JavaScript,
EventClickJavaScript = "pm.editTask(e.value())",
EventMoveHandling = EventMoveHandlingType.CallBack,
EventResizeHandling = EventResizeHandlingType.CallBack,
AfterRenderJavaScript = "afterRender(data, isCallBack)",
DynamicLoading = true,
StartDate = start,
Days = days,
EventHeight = 30,
CellWidth = 18,
CellSelectColor = "#518941",
TimeHeaders = new TimeHeaderCollection {
new TimeHeader(GroupBy.Month),
new TimeHeader(GroupBy.Day, "dddd dd"),
new TimeHeader(GroupBy.Hour)
}
})

It's not that any script errors occur, dps.update() simply doesn't do anything.
Am I missing something?

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

The MVC version receives the timeline (and the time headers) pre-generated from the server side.

You should use commandCallBack() to request a refresh from the server side (this will fire server-side Before**Render event handlers and lets you load the event set).

You can also disconnect it from the server by setting .backendUrl = null.

Comment posted by Simon
9 years ago.

Thanks.
Setting StartDate and Days serverside during a commandCallback did the trick.

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