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

Navigation

Asked by Frank Sandersen
6 years ago.

How can I do navigation (next and previous month) with the DayPilot Lite MVC month view ?

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

You can switch dates using .commandCallBack() method:

MVC View
<div class="note">
    <a href="javascript:dp.commandCallBack('previous');">Previous</a> |
    <a href="javascript:dp.commandCallBack('today');">Today</a> |
    <a href="javascript:dp.commandCallBack('next');">Next</a>
</div>

Handle OnCommand event on the server side:

MVC Controller
protected override void OnCommand(CommandArgs e)
{
  switch (e.Command)
  {
      case "previous":
          StartDate = StartDate.AddMonths(-1);
          Update(CallBackUpdateType.Full);
          break;

      case "next":
          StartDate = StartDate.AddMonths(1);
          Update(CallBackUpdateType.Full);
          break;

      case "today":
          StartDate = DateTime.Today;
          Update(CallBackUpdateType.Full);
          break;
  }
}

See also the documentation for the Pro version, it works the same way:

CommandCallBack
http://doc.daypilot.org/month/commandcallback/

Next/Previous Navigation
http://doc.daypilot.org/month/next-and-previous-buttons/

You need to upgrade to version 1.3.400 (the previous version has a bug in DayPilot.Month.commandCallBack()).

Demo:
http://mvc.daypilot.org/demo/Lite/Month/NextPrevious

Comment posted by Frank Sandersen
6 years ago.

Thanks a lot! You made my day :) I guess the solution came with version 1.3.400.

Btw, the demo project DayPilotLiteMvc-1.3.400 does not launch in VS 2013. See my screendump.

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

There was a bug in 1.3.399 that threw an exception in commadCallBack() in DayPilot.Month.

Thanks for reporting the VS 2013 issue, I will check that.

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