RadiantQ jQuery Gantt Package
How to add resource to an activity programmatically?
Previous Topic  Next Topic 

The code below illustrates how to add resource to activity in button click.


// Adding resource to activity in button click.

$("#addResource").click(function () {


    var activityview = ganttControl.SelectedItem;

    if (activityview) {

        var activity = activityview.Activity;


        var assgns = activity.Assignments;

        //1 is the resource ID.

        var selResource = activity.Model.GanttResources._resByID.GetItemByKey(1)

        if (selResource && assgns.ContainsResource(selResource) == false)

            assgns.add(new RadiantQ.Gantt.Model.ResourceAssignment(selResource));

    }

    else

        alert("Please select an item in the table first.");

    return false;


});







� RadiantQ 2022. All Rights Reserved.