2016-06-19 2 views
1

이 스케줄러가 표시되지만 작업에 바인딩되지 않았습니다. 뷰의 스케줄러. 내가 읽기/웹 API를 아래검도 스케쥴러에 약속을 저장 한 후 다른 페이지로 이동

@(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" 
    } 
}))) 

에 전화를 만들기 위해 자바 스크립트 방법을 사용하고하는 것은 내가 간결 처리기를 만들 포함하고 있지 않다 자바 스크립트 처리기 방법이다.

function customRead(options){ 
    //get the selected Row of the kendo grid 
    var selectedRow = $("#locationgridKendo").find("tbody tr.k-state-selected"); 
    var scheduler = $("#AppointmentSearchScheduler").data("kendoScheduler") 

    //get SelectedRow data 
    var rowData = $('#locationgridKendo').data("kendoGrid").dataItem(selectedRow); 

    if (rowData !== null) { 
     //Convert data to JSON 
     var rowDataJson = rowData.toJSON(); 
     //extract the location ID 
     var locationId = rowDataJson.LocationID;   
     var CalenderweekStartDate = new Date().toISOString(); 
     baseUrl = $('base').attr('href'); 
     $.ajax({ 
      url: baseUrl + 'Schedular/api/GetAppPerLocation?locationId=' + locationId + '&date=' + CalenderweekStartDate, 
      type: 'GET', 
      cache: false, 
      contentType: 'application/json',    
      success: function (result) { 
//This method is hitting and i can see the data being returned 
       console.log('data is received : ' + result.Data); 
       options.success(result.Data); 
      }, 
      error: function (xhr, status, error) { 
       //alert("Error: Search - Index.js - submitAppointment()"); 
       var err = eval("(" + xhr.responseText + ")"); 
       alert(err.Message); 
      } 
     }); 

    } 

} 

다음은 ajax 호출을 통해 호출되는 웹 API 컨트롤러입니다. 컨트롤러는 기본 읽기/쓰기 구문을 사용할 때 완벽하게 작동합니다. 아약스 호출이 완료되면 성공 메소드를 다시 실행하여 데이터를 반환하지만 어떤 이유로 든 스케줄러가 들어오는 데이터에 바인드되지 않습니다. 다음은 내 컨트롤러 코드입니다.

[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); 
} 

어떤 이유로 인해 스케줄러가 들어오는 데이터에 바인딩되지 않습니다. 들어오는 데이터가 완벽하게 작동하지만 기본 바인딩 방식을 사용하지만 전송 기능은 사용하지 않습니다. 이 접근 방식을 사용하기위한 나의 목표는 일단 내가 읽기 (스케쥴러가 지금 바인딩되지 않음)로 끝났습니다. 생성시 컨트롤러에서 반환 한 새로 생성 된 작업의 ID를 가져온 다음 해당 ID를 다른 MVC 컨트롤러로 전달하여 렌더링해야합니다 확인 페이지. 이 목표를 달성하기위한 다른 접근 방법을 적극 권장합니다.

제발 나를 실수로 용서해주세요. 제 첫 번째 질문은 stackoverflow입니다.

답변

0

내가 그 ID를 통과 한 후 내 컨트롤러 에 의해 반환 새로 만든 작업의 ​​ID를 잡아 필요가 만들에 내가 (스케줄러는 이제 바인딩되지 않음) 읽기와 함께 수행하고 나면이 방법을 사용하는 내 목표는 네비게이션 할 다른 mvc 컨트롤러에 확인 페이지을 렌더링합니다.

나는 읽기가 정확한 결과를 반환하지 않았기 때문에 나는 그것을 고쳐야 만한다고 추측했다. 또한 나의 기본 목표는 약속 ID와 함께 다른 페이지로 리디렉션하고 확인 화면을 표시하는 것이었다. 이것이 성취 된 방법입니다. 나는 이것이 최선의 접근법이 아니라는 것을 이해한다. 여기 제가 취한 접근법이 있습니다. 자바 스크립트 방법

내가 내가 여기에이

.Events(
    events => events.Error("RedirectToConfirmationPage")) 

처럼 그리드에 오류 이벤트를 구성 클라이언트 측에서

if (!String.IsNullOrEmpty(task.TaskID.ToString()))//redirect to confirmation page if the appointment was added to the queue 
    ModelState.AddModelError("AppointmentID", confirmationNumber); 

다음 내 컨트롤러에서이 같은 모델 상태에 오류가 추가된다 세부 사항

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 
      } 

     } 
    } 

희망 길 아래 사람에게 도움이됩니다.

관련 문제