We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Update gantt values and save to database

Hi,

I'd like to know how to use events to save data to database. I set the editmode to "cellEditing" and I want to save when I change values. Do I need to save every time a column lose focus, or can I save the entire line after edit?


I also need to edit using taskbar (changing progress, duration and creating dependecies by configuring predecessors). I can't get event to this. How could I save it to database?


Regards,

Otto Machado.


5 Replies

JR John Rajaram Syncfusion Team January 28, 2015 06:33 AM UTC

Hi Otto,

Thanks for using Syncfusion products.

Query

Syncfusion Comments

I'd like to know how to use events to save data to database. I set the editmode to "cellEditing" and I want to save when I change values. Do I need to save every time a column lose focus, or can I save the entire line after edit?

We can save the changes to the database that made through cellEditing by using the “EndEdit” client side event.

Please refer the following code snippets for more details.

Code snippets:

@(Html.EJ().Gantt("Gantt").

         

//...

EditSettings(eve =>

       {

           eve.AllowEditing(true);

           eve.AllowAdding(true);

           eve.AllowDeleting(true);

           eve.EditMode("cellEditing");

       }).

ClientSideEvents(eve =>

       {

           eve.EndEdit("EndEdit");

          

       }).

       Datasource(ViewBag.dataSource)

    )

@(Html.EJ().ScriptManager())

<script type="text/javascript">

        function EndEdit(args) {

            if (args.data)

                var ganttRec = args.data.item;

          

            if (args.type === 'endEdit' && args.previousValue) {

                //Edited Record is obtained here , which can be updated to database

                $.ajax({

                    type: "POST",

                    url: "/Gantt/Update"//Update is Server side method

                    data: ganttRec,

                    dataType: "json"

                });

            }

        }

    </script>

I also need to edit using taskbar (changing progress, duration and creating dependecies by configuring predecessors). I can't get event to this. How could I save it to database?

We can also save the changes to the database that made by editing the taskbar item with the help of “TaskbarEdited” client side event.

Please refer the following code snippets for more details.

Code snippets:

@(Html.EJ().Gantt("Gantt").

         

//...

AllowGanttChartEditing(true).

ClientSideEvents(eve =>

       {

           eve.TaskbarEdited("TaskbarEdited");          

       }).

       Datasource(ViewBag.dataSource)

    )

@(Html.EJ().ScriptManager())

<script type="text/javascript">

        function TaskbarEdited(args) {

            if (args.data)

                var ganttRec = args.data.item;

            if (args.type === 'taskbarEdited' && args.previousData) {

                //Edited Record is obtained here , which can be updated to database

                $.ajax({

                    type: "POST",

                    url: "/Gantt/Update"//Update is Server side method

                    data: ganttRec,

                    dataType: "json"

                });

            }

        }

    </script>

We have also prepared a sample based on this and you can find the sample under the following location:

Sample: http://www.syncfusion.com/downloads/support/directtrac/118066/SQLinMVC_CellEdit1892977364.zip

 

Please let us know if you require further assistance on this.

Regards,
John. R




OM Otto Moura Machado Filho January 28, 2015 01:49 PM UTC

Works great!

But I found that when I drag a task to another (to create a dependency), the taskBarEdited function don't fire, so I can't update the predecessor field. How can I fire the method when creating this dependencies?

In the example you send me, the field predecessor is not updated.

Thanks,
Otto Machado.


JR John Rajaram Syncfusion Team January 29, 2015 12:24 PM UTC

Hi Otto,

We were able to reproduce the issue and we have confirmed this as bug and logged a report on this. Also we have created a support incident under your account to track the status of this issue.

Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

 

Please let me know if you have any questions.

Regards,

John R




BC Bryan Conlon March 3, 2017 04:17 PM UTC

Hi was this issue ever fixed?

dragging a dependency to another seems to fire actionComplete before the mouse click is released but is there any event fired when a successful dependency is made via drag and drop?


JD Jayakumar Duraisamy Syncfusion Team March 6, 2017 01:24 PM UTC

Hi Bryan, 
Please find the response below, 
In Gantt, we can skip the validation of Predecessor when hover on connector point of another task in actionComplete event by return if the requestType  as “validatePredecessor”. Once we dropped on the valid predecessor at the time actionComplete will trigger with requestType as “recordUpdate” to update the predecessor. 
Please find the code snippet, 
<ej:Gantt ID="Ganttcontainer" 
//… 
ActionComplete="CompleteAction" 
</ej:Gantt> 
<script> 
    function CompleteAction(args) { 
        if (args.requestType == "validatePredecessor") 
            return 
        else if (args.requestType == "recordUpdate") { 
            debugger; 
        } 
    } 
</script> 
We have prepared sample for your reference, please find the sample below, 
Regards, 
Jayakumar D 


Loader.
Live Chat Icon For mobile
Up arrow icon