我正在使用剑道调度程序中的资源,如:
group: {
resources: ["Rooms"]
},
resources: [
{
name:"Rooms",
title: "Room",
field: "RoomID",
dataSource: {
autoSync: true,
transport:
{
read: { url: "@Html.Raw(Url.Action("Filter_Rooms", "Room", new{
pFilter = false,
pCapacity = 25,
pBeamer = true,
pTelevision = false
}))",dataType: "json" }
}
}
},
现在我想根据用户的输入过滤资源。所以我尝试使用javascript:
$("#btnFilter").click(function () {
if (chkBeamer.checked){
pbeamer = true;
sessionStorage
}
else {
pbeamer = false;
}
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.dataSource.transport.options.read.url = Room/Filter_Rooms/true/25/false";
scheduler.dataSource.read();
});
目标:更改计划程序的资源数据源传输读取中的参数。为了过滤资源 动态,并使用符合过滤条件的资源或房间更新调度程序。
我在这篇文章中看过这个: Kendo UI Dynamically Change Datasource String (XML)
但是当我尝试在我的情况下使用它时它不起作用并且错误:无法加载资源:服务器响应状态为405(方法不允许)。无法找到资源。
我正在使用此功能在我的控制器中进行过滤(它可以很好地进行硬编码......)
public ActionResult Filter_Rooms(bool pFilter, int pCapacity, bool pBeamer, bool Television)
{
using (var sampleDB = db)
{
if (pFilter){
IQueryable<RoomViewModel> rooms = sampleDB.Spaces.ToList().Where(r => r.roomCapacity == pCapacity && r.roomBeamer == pBeamer && r.roomCapacity == 25 && r.roomTelevision == false).ToList().Select(room => new RoomViewModel(){
roomID = room.Id,
text = room.roomName,
color = room.roomColor,
value = room.Id
}).AsQueryable();
return Json(rooms.ToList(), JsonRequestBehavior.AllowGet);
}
else{
IQueryable<RoomViewModel> rooms = sampleDB.Spaces.ToList().Select(room => new RoomViewModel(){
roomID = room.Id,
text = room.roomName,
link = "google.be",
color = room.roomColor,
value = room.Id
}).AsQueryable();
return Json(rooms.ToList(), JsonRequestBehavior.AllowGet);
}
}
}
那么如何动态更改这些参数以过滤调度程序的资源?