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

How to send custom data to backend

Asked by Isaac
11 years ago.

I need to pass several filter values to the Backend action of my controller through a DayPilotControl and DayPilotNavigator components. How can this be accomplished?

The view is defined using the MVC razor helper like so:

@Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig(Old.Theme)
{
ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType.Week,
ShowAllDayEvents = true,
AllDayEventHeight = 25,
CssOnly = true,
//EventBubble = "bubble",
CssClassPrefix = "calendar_blue",
BackendUrl = Href("~/Calendar/Backend"),
Height = 800,
HeightSpec = DayPilot.Web.Mvc.Enums.Calendar.HeightSpec.Full,
StartDate = ViewBag.Helper.DateRangeStart,
DayBeginsHour = 6,
DayEndsHour = 21,

})

The Backend action passes the request on to a subclass of DayPilotCalendar (CalendarComponent):

public ActionResult Backend()
{
_calendarHelper.Init(Request);
Response.Cache.SetNoServerCaching();
Response.Cache.SetNoStore();
return new CalendarComponent(Request, _calendarService, _sessionService, _calendarHelper).CallBack(this);
}

If I could get some custom data into the post request that is sent back by the dpc object I could take it from there since I can get the request context and do whatever I need to through the Callback action.

So basically I just need to know how to trigger a refresh on the dpc object and specify some custom parameters to send back to the Backend action.

Comment posted by Isaac
11 years ago.

The best way I've found around this was to pack the extra filter data into the BackendUrl value. Filters cause a page refresh, during which I also grab the current StartDate so the refreshed calendar is on the right spot. Kind of a kludge but it will work for now until a real answer is available.

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

Hi Isaac,

You should be able to pass custom data to the server using .clientState property:

http://doc.daypilot.org/calendar/clientstate/

ClientState is persisted until the page is refreshed and it is sent to the server with every request.

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