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

DaypilotNavigator JS-select incorrect behaviour

Asked by Dmitry
13 years ago.

Hello.

When use dpn.select(dt) with dt not in visible range navigator should always switch to month which contains selected date.

Now the logic is sometimes incorrect, especially when you try to implement "prev - next" logic. It seems that you use a 90 days interval logic to switch visible range. It is not correct, it must be more complex. Just try dt.AddDays(7) and you will see that switching not always happens when you expect it to happen.

The logic should be somthing like that:

with (DPNavigator) {
var endDate = startDate.addMonths(showMonths);
if ((selectionStart.d < startDate.d && selectionEnd.d < startDate.d) || (selectionStart.d >= endDate.d && selectionEnd.d >= endDate.d)) {
moveMonth((selectionStart.d < startDate.d ? -1 : 1) * skipMonths);
}

Comment posted by Dmitry
13 years ago.

Or maybe more simple: you can just check if selection is visible by cssClass and if not then switch to needed month

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