2014-03-05 56 views
2

如何在數據綁定到調度器後從Kendo調度器中檢索數據。在網格數據綁定後,我設置了一個JavaScript函數來觸發。當這個javascript函數觸發時,我需要從網格中獲取數據源。綁定後得到kendo調度器數據源

@(Html.Kendo().Scheduler<Optic_Freedom.Areas.Scheduling.Models.CalendarViewModel>() 
      .Name("scheduler") 
      .Date(new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day)) 
      .StartTime(new DateTime(2013, 6, 13, 07, 00, 00)) 
      .EndTime(new DateTime(2013, 6, 13, 23, 00, 00)) 
      .Editable(false) 
      .Height(900) 
      .Events(e=> e.DataBound("someFunction")) 
      .EventTemplate(
       "<div style='font-size:8pt;'>#= kendo.toString(title) # - #= kendo.toString(start, 'HH:mm') # - #= kendo.toString(end, 'HH:mm') # (#= kendo.toString(TotalPersonnel) #)</div>" 
      ) 
      .Views(views => 
      { 
       views.DayView(); 
       views.MonthView(month => month.Selected(true).DayTemplate("<div id=\"DayClass\" style='float:left'><span class=\"theDate\">#= kendo.toString(date, 'dd')#</span> - (<span id=\"PersonnelDayCount\"/>)</div>")); 
       views.AgendaView(a =>a.Title("Event List")); 
      }) 
      .DataSource(d => d 
      .Model(m => m.Id(f => f.Id)) 
      .Read("GetSchedule", "ScheduleHome") 
      ) 
    ) 

--javascript函數試圖獲取數據

function someFunction(e) { 
     var model = $("#scheduler").data("kendoScheduler"); 
     -- can't get the model data 
} 

我需要什麼就擺在someFunction(E)來獲取數據?

回答

1

我需要 VAR模型= $( 「#調度程序」)的數據( 「kendoScheduler」)數據源;

然後從那裏我可以循環瀏覽模型 $ .each(model.data(),function(index,item){do something ...});

5

我假定你正在尋找:

var data = this.dataSource.data(); 
相關問題