Вопрос

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:

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

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

enter image description here

Это было полезно?

Решение

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..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top