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

Schedule doesn't update when use navigation

Asked by Vatthanachai W.
7 years ago.

Hi,
I'm just create the "previous | today | next" to navigation the scheduler to change the start date from this tutorial [https://doc.daypilot.org/scheduler/next-and-previous-buttons/], but it's not work. Can you help me about this?

::: Code in view :::
[code]
@using DayPilot.Web.Mvc
@using DayPilot.Web.Mvc.Enums
@using DayPilot.Web.Mvc.Events.Scheduler;
@using DayPilot.Web.Mvc.Enums.Scheduler;

@{
ViewBag.Title = "Home Page";
}

@Scripts.Render("~/bundles/daypilot")

<div class="row">
<a href="javascript:dps.commandCallBack('previous');" class="btn btn-default" style="width: 81px;">Previous</a> |
<a href="javascript:dps.commandCallBack('today');" class="btn btn-default" style="width: 81px;">Today</a> |
<a href="javascript:dps.commandCallBack('next');" class="btn btn-default" style="width: 81px;">Next</a>
</div>
<div class="row">
@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig
{
BackendUrl = Url.Action("SchedulerBackEnd", "Home"),
Scale = TimeScale.Manual,
Days = 7,
WeekStarts = WeekStarts.Sunday,
Width = "100%",
TimeHeaders = new TimeHeaderCollection()
{
new TimeHeader(GroupBy.Month),
new TimeHeader(GroupBy.Day)
},
CellWidth = 107,
RowMinHeight = 10,
EventMovingStartEndEnabled = true,
MoveBy = DragArea.Full,
TreeEnabled = true,
TreePreventParentUsage = false
})
</div>
[/code]

::: Code in Controller :::
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DayPilotSchedulerNavigateDemo.Helpers;

namespace DayPilotSchedulerNavigateDemo.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

public ActionResult SchedulerBackEnd()
{
var scheduleHelper = new SchedulerHelper();
return scheduleHelper.CallBack(this);
}
}
}
[/code]

::: Code in helper :::
[code]
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Enums;
using DayPilot.Web.Mvc.Enums.Scheduler;
using DayPilot.Web.Mvc.Events.Scheduler;
using WebGrease.Css.Extensions;

namespace DayPilotSchedulerNavigateDemo.Helpers
{
public class SchedulerHelper : DayPilotScheduler
{
protected override void OnInit(InitArgs e)
{
var startDate = DateTime.Today;
var endDate = DateTime.Today.AddDays(7);

Timeline = new TimeCellCollection();
for (DateTime cell = startDate; cell < endDate; cell = cell.AddDays(1))
{
Timeline.Add(cell, cell.AddDays(1));
}

LoadResource();

Separators.Clear();
Separators.Add(DateTime.Today, Color.CornflowerBlue, SeparatorLayer.BelowEvents, 50, 50);

Update(CallBackUpdateType.Full);
}

class Employees
{
public int ID { get; set; }
public string Name { get; set; }
}

void LoadResource()
{
var emps = new List<Employees>
{
new Employees
{
ID = 1,
Name = "AAA"
},
new Employees
{
ID = 2,
Name = "BBB"
},
new Employees
{
ID = 3,
Name = "CCC"
},
};

var nResource = emps.Select(s => new Resource
{
Id = s.ID.ToString(),
Name = s.Name
});

nResource.ForEach(s => Resources.Add(s));
}

protected override void OnCommand(CommandArgs e)
{
switch (e.Command)
{
case "previous":
StartDate = StartDate.AddDays(-7);
break;
case "today":
StartDate = DateTime.Today.AddDays(-7);
break;
case "next":
StartDate = StartDate.AddDays(7);
break;
case "refresh":
break;
}

Update(CallBackUpdateType.Full);
}
}
}
[/code]

Answer posted by Vatthanachai W.
7 years ago.

Sorry I'm got it.
must be change the "Scale = TimeScale.Manual" to "Scale = TimeScale.Day"

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

Great, thanks for the update.

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