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
- Handle the
edit
event of the Gantt. - In the
edit
event, retrieve and store the start and end date in global variables. -
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(); }
-
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 } }