Kendo ui 在kendo scheduler中保存约会后导航到另一页
我已显示此计划程序,但未绑定到任务。视图中的计划程序。我正在使用java脚本方法读取/创建对web api的调用Kendo ui 在kendo scheduler中保存约会后导航到另一页,kendo-ui,kendo-asp.net-mvc,kendo-scheduler,Kendo Ui,Kendo Asp.net Mvc,Kendo Scheduler,我已显示此计划程序,但未绑定到任务。视图中的计划程序。我正在使用java脚本方法读取/创建对web api的调用 @(Html.Kendo().Scheduler<TaskViewModel> () .Name("AppointmentSearchScheduler") .DataSource(dataSource => dataSource .Custom() .Schema(schema => schema .Model(m => { m.Id(f =&g
@(Html.Kendo().Scheduler<TaskViewModel> ()
.Name("AppointmentSearchScheduler")
.DataSource(dataSource => dataSource
.Custom()
.Schema(schema => schema
.Model(m => {
m.Id(f => f.TaskID);
m.Field(f => f.OwnerID).DefaultValue(1);
}))
.Transport(new {
read = new Kendo.Mvc.ClientHandlerDescriptor() {
HandlerName = "customRead"
},
create = new Kendo.Mvc.ClientHandlerDescriptor() {
HandlerName = "customCreate"
}
})))
下面是通过进行ajax调用调用的WebAPI控制器。当我使用基本的读取/创建语法时,控制器工作得非常好。ajax调用完成,它会回击success方法并返回数据,但由于某些原因,调度程序没有绑定到传入数据。这是我的控制器代码
[HttpGet]
[Route("api/GetAppPerLocation")]
public DataSourceResult GetAppointmentPerLocation([ModelBinder(typeof(Usps.Scheduling.Web.ModelBinders.DataSourceRequestModelBinder))] DataSourceRequest request, int locationId, DateTime date) {
List < TaskViewModel > locationAvailableAppointmentList = new List < TaskViewModel > ();
locationAvailableAppointmentList = data.Select(appt => new TaskViewModel() {
TaskID = appt.ServiceAppointmentId,
Title = "Appointment Available",
Start = DateTime.SpecifyKind(appt.AppointmentBegin, DateTimeKind.Local),
End = DateTime.SpecifyKind(appt.AppointmentEnd, DateTimeKind.Local),
Description = "",
IsAllDay = false
}).ToList();
return locationAvailableAppointmentList.ToDataSourceResult(request);
}
[HttpGet]
[路线(“api/GetAppPerLocation”)]
公共数据源结果GetAppointmentPerLocation([ModelBinder(typeof(Usps.Scheduling.Web.ModelBinders.DataSourceRequestModelBinder))]DataSourceRequest请求,int locationId,DateTime日期){
ListlocationAvailableAppointmentList=新列表();
locationAvailableAppointmentList=data.Select(appt=>new TaskViewModel(){
TaskID=appt.ServiceAppointId,
Title=“可预约”,
Start=DateTime.SpecifyKind(appt.AppointmentBegin,DateTimeKind.Local),
End=DateTime.SpecifyKind(appt.AppointmentEnd,DateTimeKind.Local),
Description=“”,
IsAllDay=false
}).ToList();
返回LocationAvailableAppointList.ToDataSourceResult(请求);
}
由于某些原因,调度程序未绑定到传入数据。当我使用基本绑定方法但不使用传输时,传入数据可以完美地工作我使用这种方法的目标是,一旦我完成了read(调度器现在没有绑定),在创建时,我需要获取控制器返回的新创建任务的ID,然后将该ID传递给另一个mvc控制器以呈现确认页面。强烈建议采用任何其他方法来实现此目标。
function RedirectToConfirmationPage(e) {
console.log('RedirecToConfirmationPage method......');
console.log(e);
if (e.errors) {
var appointmentID = "";
// Create a message containing all errors.
$.each(e.errors, function (key, value) {
console.log(key);
if ('errors' in value) {
$.each(value.errors, function () {
appointmentID += this + "\n";
});
}
});
console.log('Newly Generated AppointmentID = ' + appointmentID);
// Redirect URL needs to change if we're running on AWS instead of on local developer machines
if (window.location.href.indexOf('/TestProject.Scheduling') > 1) {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
else {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
}
}
请原谅我的任何错误,因为这是我关于stackoverflow的第一个问题
我使用这种方法的目标是,一旦我完成了read(调度器现在没有绑定),在创建时,我需要获取控制器返回的新创建任务的ID,然后将该ID传递给另一个mvc控制器以导航并呈现确认页面
我推测read并没有返回正确的结果,所以我必须解决这个问题。我的基本目标是在使用约会id并显示确认屏幕后重定向到另一个页面。这就是它是如何完成的。我知道这不是最好的办法,但一年多以来,没有任何机构回答这个问题。以下是我采取的方法
我在控制器中向模型状态添加了一个错误,如下所示
if (!String.IsNullOrEmpty(task.TaskID.ToString()))//redirect to confirmation page if the appointment was added to the queue
ModelState.AddModelError("AppointmentID", confirmationNumber);
然后在客户端,我像这样在网格上配置错误事件
.Events(
events => events.Error("RedirectToConfirmationPage"))
下面是Javascript方法的详细信息
function RedirectToConfirmationPage(e) {
console.log('RedirecToConfirmationPage method......');
console.log(e);
if (e.errors) {
var appointmentID = "";
// Create a message containing all errors.
$.each(e.errors, function (key, value) {
console.log(key);
if ('errors' in value) {
$.each(value.errors, function () {
appointmentID += this + "\n";
});
}
});
console.log('Newly Generated AppointmentID = ' + appointmentID);
// Redirect URL needs to change if we're running on AWS instead of on local developer machines
if (window.location.href.indexOf('/TestProject.Scheduling') > 1) {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
else {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
}
}
希望对以后的人有帮助
我使用这种方法的目标是,一旦我完成了read(调度器现在没有绑定),在创建时,我需要获取控制器返回的新创建任务的ID,然后将该ID传递给另一个mvc控制器以导航并呈现确认页面
我推测read并没有返回正确的结果,所以我必须解决这个问题。我的基本目标是在使用约会id并显示确认屏幕后重定向到另一个页面。这就是它是如何完成的。我知道这不是最好的办法,但一年多以来,没有任何机构回答这个问题。以下是我采取的方法
我在控制器中向模型状态添加了一个错误,如下所示
if (!String.IsNullOrEmpty(task.TaskID.ToString()))//redirect to confirmation page if the appointment was added to the queue
ModelState.AddModelError("AppointmentID", confirmationNumber);
然后在客户端,我像这样在网格上配置错误事件
.Events(
events => events.Error("RedirectToConfirmationPage"))
下面是Javascript方法的详细信息
function RedirectToConfirmationPage(e) {
console.log('RedirecToConfirmationPage method......');
console.log(e);
if (e.errors) {
var appointmentID = "";
// Create a message containing all errors.
$.each(e.errors, function (key, value) {
console.log(key);
if ('errors' in value) {
$.each(value.errors, function () {
appointmentID += this + "\n";
});
}
});
console.log('Newly Generated AppointmentID = ' + appointmentID);
// Redirect URL needs to change if we're running on AWS instead of on local developer machines
if (window.location.href.indexOf('/TestProject.Scheduling') > 1) {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
else {
window.location.href = '/Scheduler/AppointmentConfirmation?confirmationNumber=' + appointmentID
}
}
}
希望对以后的人有帮助