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

Binding Calendar Events to Backend Stored Procedure Dataset

Asked by Jason
11 years ago.

Hi there I am trying to bind the daypilotMonth to a controller that returns data from a stored procedure as below :

Protected Overrides Sub OnInit(ByVal e As DayPilot.Web.Mvc.Events.Month.InitArgs)

Dim db2 = New R32_LiveEntities1

Dim Events As List(Of SSC_Identify_Holidays_By_Line_Manger_Result)

'Events = db2.ExecuteStoreQuery(Of SSC_Identify_Holidays_By_Line_Manger_Result)("SSC_Identify_Holidays_By_Line_Manger").ToList

Events = db2.ExecuteStoreQuery(Of SSC_Identify_Holidays_By_Line_Manger_Result)("SSC_Identify_Holidays_By_Line_Manger").ToList

DataIdField = Events.FirstOrDefault.RowNum
DataTextField = Events.FirstOrDefault.Employee
DataStartField = Events.FirstOrDefault.Annual_Leave_Day
DataEndField = Events.FirstOrDefault.Annual_Leave_Day

Update()

End Sub

however I know the SP returns data and have amended dates to return in current month , so i would expect to see values but the calendar does not bind. Apologies if this is something very stupid as i am new to MVC and Javascript.

Regards

Jason

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

These properties should actually hold the names of the fields/columns in the list:

DataIdField = "RowNum"
DataTextField = "Employee"
DataStartField = "Annual_Leave_Day"
DataEndField = "Annual_Leave_Day"

Let me know if it didn't help.

Comment posted by Jason
11 years ago.

Many thanks for a speedy response I have amended this in the controller now but still no data returned to the front end. I can debug it and see that data is being returned from Controller - ia have attached the code of my view incase it is something - it worked using the example of dataadapter and datatables but i want to mone away from that

Thanks again

Controller :

Public Function Backend() As ActionResult
Return New Dpm().CallBack(Me)
End Function

Public Class Dpm

Inherits DayPilotMonth

Protected Overrides Sub OnInit(ByVal e As DayPilot.Web.Mvc.Events.Month.InitArgs)

Dim db2 = New R32_LiveEntities1

Dim Events As List(Of SSC_Identify_Holidays_By_Line_Manger_Result)

Events = db2.ExecuteStoreQuery(Of SSC_Identify_Holidays_By_Line_Manger_Result)("SSC_Identify_Holidays_By_Line_Manger").ToList

DataIdField = "RowNum"
DataTextField = "Employee"
DataStartField = "Annual_Leave_Day"
DataEndField = "Annual_Leave_Day"

Update()

End Sub

View :

@imports DayPilot.Web.Mvc
@imports DayPilot.Web.Mvc.Enums
@imports DayPilot.Web.Mvc.Events.Month
@imports DayPilot.Web.Mvc.DayPilotMonth

<select id="dropdown" onchange="this.form.submit();">

@Code

Dim first As DateTime = New DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)

For i As Integer = 0 To 12

Dim d = first.AddMonths(i)

@<option value="@d.ToString("s") %>">@d.ToString("MMMM yyyy")</option>

Next

End Code

</select>

<h2 style="margin:0px;padding:0px;">Calendar Of Holidays</h2>
<div style="margin-bottom: 10px;"></div>

<script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/month.js")" type="text/javascript"></script>

<div id="dpm">

<script type="text/javascript">
var dp;

$(document).ready(function () {
dp = $("#dpm").daypilotMonth({
backendUrl: '@Url.Content("~/Home/Backend")',
});
});
</script>

<script type="text/javascript">

$("#dropdown").change(function() {
var selected = $(this).val();
dpm.commandCallBack("navigate", {start: selected});
});
</script>

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

I would recommend checking the AJAX response sent by the server after the control is initialized. It fires the server-side OnInit event and the response will include a JSON object with the event list and other properties. You can check it using Firebug/Firefox or Developer Tools in Chrome or IE.

The response usually looks like this:

{"Events":[{"id":"1","areas":null,"text":"Event 1","recurrentMasterId":null,"start":"2013-04-29T15:00:00","end":"2013-04-29T15:00:00","recurrent":false,"sort":null,"toolTip":"Event 1","tag":[]},{"id":"2", ...

You should inspect the Events property to see if it contains the data you expect.

You can also post it here for a review.

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