简体   繁体   English

KendoUI调度程序

[英]KendoUI Scheduler

I am trying to implement the scheduler control to show live calculation of material usage on daily bases (in a week by week view). 我正在尝试实施调度程序控件,以显示每日基础上的材料使用情况的实时计算(按周查看)。

I am unable to have the Usage data displayed in the cells although I managed to have to Materials displayed on the left hand side. 虽然我设法在左侧显示材料,但我无法在单元格中显示使用数据。 I wonder if any one could help or give me some hints on what I am doing wrong. 我想知道是否有人可以帮助或给我一些关于我做错的提示。 Here is my code so far: 到目前为止,这是我的代码:

I can be sure that data is being return to the view but the view is not showing the usage data, which is simply numeric values corresponding to a material on a specific day of the week. 我可以确定数据正在返回到视图,但视图没有显示使用数据,这只是与一周中特定日期的材料相对应的数值。 I have also attached a screenshot of how it looks like: 我还附上了它的样子截图:

the Controller method to read the data: Controller方法读取数据:

public JsonResult Read([DataSourceRequest] DataSourceRequest request)
{
    try
    {
        var usageList = new List<ReportUsageViewModel>();

        var imports = _importRespository.GetImports();

        foreach (var usageReportStoredProcedure in imports)
        {
            var usageViewModel = new ReportUsageViewModel();

            usageViewModel.MaterialID = usageReportStoredProcedure.MaterialID;
            usageViewModel.Start = usageReportStoredProcedure.ScanDate;
            usageViewModel.End = usageReportStoredProcedure.ScanDate;
            usageViewModel.DailyUsage = usageReportStoredProcedure.UsageQuantity;
            usageViewModel.Title = usageReportStoredProcedure.UsageQuantity.ToString();

            usageList.Add(usageViewModel);
        }


        return Json(usageList.ToDataSourceResult(request));

    }
    catch (Exception exc)
    {
        ErrorHelper.WriteToEventLog(exc);
        return null;

    }
}

The actual control 实际控制

<div id="StockViewer">
    @(Html.Kendo().Scheduler<WorcesterMarble.ViewModels.ReportUsageViewModel>()
    .Name("StockViewer")
    .Timezone("Europe/London")
    .Resources(resource => resource.Add(m => m.MaterialID)
        .Title("Materials")
        .Name("Materials")
        .DataTextField("Name")
        .DataValueField("MaterialID")
        .BindTo(Model.MaertiaList))
    .MajorTick(270)
    .MinorTickCount(1)

    .StartTime(DateTime.Now.Date.AddHours(8))
    .EndTime(DateTime.Now.Date.AddHours(17))
    .AllDaySlot(false)
    .Date(DateTime.Now.Date)
    .Editable(false)
    .Views(x => x.WeekView(v =>
    {
        v.Footer(false);
        v.Selected(true);
        v.DateHeaderTemplate("<span class='k-link k-nav-day'>#=kendo.toString(date, 'ddd dd/M')#</span>");
    }))
    .Group(group => group.Resources("Materials").Orientation(SchedulerGroupOrientation.Vertical))
        .DataSource(d => d
        .Model(m => {
            m.Id(f => f.MaterialID);
            m.Field(f => f.Title).DefaultValue("No title"); 
        })
        .Read("Read", "ReportUsage")
    )
    )

Update: This is the ViewModel implementing the ISchedulerEvent 更新:这是实现ISchedulerEvent的ViewModel

  public class ReportUsageViewModel : ISchedulerEvent
    {
        public int MaterialID { get; set; }
        public string MaterialName { get; set; }
        public int? DailyUsage { get; set; }

        public List<MaterialViewModel> MaertiaList { get; set; }

        public string Description { get; set; }

        public System.DateTime End { get; set; }

        public bool IsAllDay { get; set; }

        public string RecurrenceException { get; set; }

        public string RecurrenceRule { get; set; }

        public System.DateTime Start { get; set; }

        public string Title { get; set; }
    }

在此输入图像描述

The issue was in these two lines: 问题出在以下两个方面:

.StartTime(DateTime.Now.Date.AddHours(8)) 
.EndTime(DateTime.Now.Date.AddHours(17)) 

The data was there but these two lines were hiding it. 数据在那里,但这两行隐藏了它。 The data was being logged at times outside the time range of 8 to 17 so I removed these two lines and then set the Major ticks to 1440, which is the total number of ticks in 24 hrs, which helped me hiding the time column as I didn't need it.. 数据在8到17的时间范围之外被记录,所以我删除了这两行,然后将Major ticks设置为1440,这是24小时内的总滴答数,这有助于我隐藏时间列,因为我不需要它..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM