我需要 MVC 3 应用程序中的调度程序。在控制器中:
public ActionResult Data()
{
List<MyCalendar> data = _iManageVendors.GetAllCalendarDetails();
return View(data);
}
这里的数据将从数据库中检索所有值,其 View Data.cshtml 是
@model dynamic
@{
Response.ContentType = "text/xml";
}
<data>
@{ foreach (var myevent in Model) {
<MyCalendars id="@myevent.Id">
<StartDate><![CDATA[ @String.Format("{0:MM/dd/yyyy HH:mm}",myevent.StartDate) ]]></StartDate>
<EndDate><![CDATA[ @String.Format("{0:MM/dd/yyyy HH:mm}",myevent.EndDate) ]]></EndDate>
<Text><![CDATA[ @myevent.Text]]></Text>
</MyCalendars>
}
}
</data>
它是一个 xml 视图.. 和 Index.cshtml
@{
ViewBag.Title = "Home Page";
Layout = null;
}
<head>
<script src="http://www.codeproject.com/Scripts/dhtmlxscheduler.js" type="text/javascript"></script>
<link href="http://www.codeproject.com/Scripts/dhtmlxscheduler.css" rel="stylesheet" type="text/css" />
<style type="text/css">
html, body
{
height:100%;
padding:0px;
margin:0px;
}
</style>
<script type="text/javascript">
function init() {
debugger;
alert(scheduler);
scheduler.config.xml_date = "%m/%d/%Y %H:%i";
scheduler.init("scheduler_here", new Date(2013, 6, 1), "month");
scheduler.load("/Home/Tasks");
var dp = new dataProcessor("/Home/Save");
dp.init(scheduler);
dp.setTransactionMode("POST", false);
}
</script>
</head>
<body onload="init()">
<div id="scheduler_here" class="dhx_cal_container" style='width: 100%; height: 100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button">
</div>
<div class="dhx_cal_next_button">
</div>
<div class="dhx_cal_today_button">
</div>
<div class="dhx_cal_date">
</div>
<div class="dhx_cal_tab" name="day_tab" style="right: 204px;">
</div>
<div class="dhx_cal_tab" name="week_tab" style="right: 140px;">
</div>
<div class="dhx_cal_tab" name="month_tab" style="right: 76px;">
</div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
</body>
但是当我加载页面时,日历视图即将到来,但 xml 中出现了一些错误。任何人都可以帮我解决这个问题吗?