Edit this page

Change MVC Gantt Resources Depending on the Edited Task

Environment

Product Telerik UI for ASP.NET MVC Gantt

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

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy