New to Kendo UI for jQuery? Download free 30-day trial

Change the Resources of Gantt for ASP.NET MVC Depending on the Edited Task

Environment

Product Progress® Telerik® UI Gantt for ASP.NET MVC

Description

How can I populate the Assignments edit dialog based on the StartDate and EndDate of the edited task after checking from the server which are the resources that are available for the selected date and time?

Solution

  1. Handle the edit event of the Gantt.
  2. In the edit event, retrieve and store the start and end date in global variables.
  3. Trigger the read() call on the Resources DataSource.

    function onEdit(e) {
      var task = e.task;
      var gantt = e.sender;
    
      window.start = task.start;
      window.end = task.end;
    
      gantt.resources.dataSource.read();
    }
    
  4. Configure a Data() function for the Resources Read action. As a result, you will be able to filter the returned Resources based on the start and end time of the task on the server.

    .Resources(r => r
        .Field("resources")
        .DataColorField("Color")
        .DataTextField("Name")
        .DataSource(d => d
            .Custom()
            .Schema(s => s
                .Model(m => m.Id("ID"))
                .Data("Data")
            )
            .Transport(t =>
            {
                t.Read("ReadResources", "Gantt").Data("onResourcesRead");
            })
        )
    )
    
    function onResourcesRead() {
      return {
        start: window.start,
        end: window.end
      }
    }
    

See Also

In this article