RadiantQ jQuery Gantt Package
How to add data asynchronously while on expanding the node?
Previous Topic  Next Topic 


"dynamicResolverFunction" is called everytime the user expands a node in the grid and which will add the child data asynchronously while on expanding the node. Here is the code that shows how to do that.


$("#gantt_container")..FlexyGantt({

    ...............

    ...............

    dynamicResolverFunction: function (data, hierItem) {

        if (hierItem.isExpanding) {

            if (data.Resources.length == 0) {

                // To let gantt know the child items processed async.

                hierItem.isUpdatingChildListAsync = true;

                getChildTasksAsync(data, hierItem);

                return [];

            }

            else

                return data.Resources;

        }

        // Return an empty array to stay the row as parent.

        return [];

    }


    getChildTasksAsync = function (data, hierItem) {

        // Doing this in a 2 secs timeout, just to simulate loading data from server.

        setTimeout(function () {

            var childData = new Array();

            for (i = 1; i <= 50; i++) {

                var resources = {

                    "RName": "Resource" + i,

                    "Tasks": [{

                        "TaskName": "Task 1",

                        "StartTime": Date.today().addDays(-10),

                        "EndTime": Date.today().addDays(1),

                        "Progress": 20

                    },

                    {

                        "TaskName": "Task 2",

                        "StartTime": Date.today().addDays(2),

                        "EndTime": Date.today().addDays(20),

                        "Progress": 50

                    }]

                }

                childData.push(resources);

            }

            hierItem.UpdateDynamicResolvedChildList(childData);

            return childData;

        }, 2000);

    }

});

       


This is illustrated in this samples:


In HTML                : ..\Samples\FGLoadChildrenOnDemand.htm

In ASP.NET MVC     : ..\Views\Home\FlexyGantt\FGLoadChildrenOnDemand.cshtml.

In ASP.NET            : ..\Samples\FlexyGantt\FGLoadChildrenOnDemand.aspx.




� RadiantQ 2022. All Rights Reserved.