1

嗨,我正在使用带有 mvc razor 的 dhtmlx 调度程序。

我已经创建了单位选项卡。但我不知道如何在不同的单位之间划分事件。这是我的示例代码。

Scheduler.InitialDate = DateTime.Now.Date;// the initial data of Scheduler   
var unit = new UnitsView("Employee", "EmpID");//initializes the view
var rooms = new List<object>(){
    new { key = "1", label = "Employee1"},
    new { key = "2", label = "Employee2"},
    new { key = "3", label = "Employee3"},
    new { key = "4", label = "Employee4"}
};
unit.AddOptions(rooms);
Scheduler.Views.Add(unit);

我通过存储过程获取 ID 和显示名称,现在我在设置key=IDand时遇到了问题label= displayname

请帮助我在调度程序单元视图中显示名称。我首先在 mvc3 razor 中使用实体数据库

这是我已经尝试过但在中间敲击的代码,

var unit = new UnitsView("units", "resourcename");
scheduler.Views.Add(unit);
List<GetResourceOrderDisplay_Result> resourcedisplayname = 
           new List<GetResourceOrderDisplay_Result>();
resourcedisplayname = _scheduler.Getresorderdisplay();
DashboardViewModel objDashboardViewModel = new DashboardViewModel();
var options = new List<object>();
//how to add key and label from the result i'm getting from resourcedisplayname?

unit.AddOptions(options);

>

public partial class GetResourceOrderDisplay_Result
{
    public int ID { get; set; }
    public string DisplayName { get; set; }
}

模型:

public class DashboardViewModel
{
    //scheduler unitsview
    public int ID { get; set; }
    public string DisplayName { get; set; }
}

这是我从存储过程中获取 Id 和显示名称的地方

public List<GetResourceOrderDisplay_Result> Getresorderdisplay()
{
    List<GetResourceOrderDisplay_Result> oGetresorderdisplay = 
                  new List<GetResourceOrderDisplay_Result>();

    oGetresorderdisplay = dbContext.GetResourceOrderDisplay().ToList();

    return oGetresorderdisplay.ToList();
}

谢谢 PKKG 的宝贵时间 :) 我解决了这个问题。这是解决方案,请在下面留下评论以进行改进:) ​​ 解决方案:

     var unit = new UnitsView("units", "ID");
...............
......

         var options = new List<object>();
                      foreach (var name in resourcedisplayname)
                      {


   options.Add(new { key = name.ID, label = name.DisplayName });
                  }
                unit.AddOptions(options);
4

0 回答 0