RadiantQ jQuery Gantt Package
Creating Custom Undo Actions
Previous Topic  Next Topic 

Creating Custom Undoable Actions is very easy. Create a custom type like the following:


    yourCustomAction = function(){

        this.DeleteDependencyAction = function()

        {

        }

        this.ExecuteCore = function()

        {

            // Code to execute (redo) the action

        }


        this.UnExecuteCore = function()

        {

            // Code to undo the action.

        }

    }


And create a new action and add it to the ActionManager as follows:


var yourAction = new yourCustomAction(ganttControl, activity, ...whatever else...);

ganttControl.ActionManager.RecordAction(yourAction);


Note that when you create a custom action type, remember not to cache any objects that could technically become deleted from the gantt model or view and would become obsolete by the time undo happens. For example, do not cache IActivity instances, instead cache the id of the activity using which you can look up an IActivity instance whenever necessary.



© RadiantQ 2022. All Rights Reserved.