2014-03-31 3 views
0

juts 전체 일정에이보기 단추를 인쇄하면 현재보기에있는 날짜 범위를 사용하고보다 프린터 친화적 인 버전의 달력을 생성합니다. 이것은 컨트롤러의 시작입니다. url 매개 변수를 사용하는 MVC4 URL 동작

 public ActionResult PrintableCalendar(string start, string end) 
    { 
     DateTime StartTime = Convert.ToDateTime(start); 
     DateTime EndTime = Convert.ToDateTime(end); 
     EndTime = EndTime.AddDays(-1); 


     ClientContext clientContext = new ClientContext(WebConfigurationManager.AppSettings["SPSite"]); 
     Web site = clientContext.Web; 

<script type="text/javascript"> 
    $('#PrintView').click(function() { 
     var currentCalendarView = $('#calendar').fullCalendar("getView"); 
     var startDate = currentCalendarView.visStart; 
     var endDate = currentCalendarView.visEnd; 
     window.open(@Url.Action("PrintableCalendar", "OnCall", new{start=startDate.toString(), end=endDate.toString()})); 
    }); 
</script> 

너무 베어 MVC 새로운이 버튼의 클릭 기능입니다

<input type="button" id="PrintView" name="PrintView" value="Print This View" /> 

초기 calnedar .... 임에 버튼 그게 전부입니다 UPDATE ... 이것은 달력 생성을 위해 같은 뷰에서 처음에 호출됩니다.

<script type='text/javascript'> 

    $(document).ready(function() { 

     $('#calendar').fullCalendar({ 
      editable: true, 
      data: JSON.stringify(), 
      eventRender: function(event, element) { 
       element.find('span.fc-event-title').html(element.find('span.fc-event-title').text()); 
      }, 
      events: "@(Url.Action("GetEvents", "OnCall"))", 
      header: { 
       left: 'prev,next today', 
       center: 'title', 
       right: 'month,agendaWeek,agendaDay' 
      }, 


      loading: function(bool) { 
       if (bool) $('#loading').show(); 
       else $('#loading').hide(); 
      } 

     }); 

    }); 

</script> 
+0

무엇이 문제입니까? – haim770

+0

'route.config' 파일에 커스텀 매개 변수로 라우트를 설정 했습니까? – mituw16

+0

실제로 내 페이지를 trappping하고 오류가 발생했다는 것을 말하면 페이지가 다른 스크립트에서로드 될 때 다른 URL.action이 호출되기 때문에 발생합니다. – KBriz

답변

1

JS를 .Net 매개 변수와 혼합합니다.

window.open('@Url.Action("PrintableCalendar", "OnCall", null)?start=startDate&end=endDate'); 

(일부 인용하고 통화에서 toDateString()과 잊어 버렸)

window.open('@Url.Action("PrintableCalendar", "OnCall", null)?start=' + startDate.toDateString() + '&end=' + endDate.toDateString()); 
0

당신이 시도를 [당신이 나를 시정 후에 EDIT], 그것은 도움이 특정 호출하여 마지막 줄을 교체하십시오 동작 및 매개 변수가있는 컨트롤러.

window.location.href = "@ Url.Action ("Action ","Controller ")"+ "/"+ "매개 변수;

관련 문제