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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add Above Below Action

Thread ID:

Created:

Updated:

Platform:

Replies:

121423 Dec 13,2015 09:12 AM UTC Dec 24,2015 12:21 PM UTC ASP.NET MVC 9
loading
Tags: Gantt
Prasanth
Asked On December 13, 2015 09:12 AM UTC

Hi there,

I have come across a strange behaviour with Gantt control.  I have attached the cshtml file along with this thread

I have Add Update controller methods to handle data save into SQL database.  The scenario is this

let's say I have saved couple of tasks with ID 1 and 2 respectively no issues here.  When I revisit this page at later stage  If I try to click on Add Above both Add and Update controller methods gets fired.  Also if I click "Add Above" on Task 2,  There is a new record created with Task 3 but Task 2's Id is updated to 3 also.  So I end up having 2 Tasks with same ID.  

However this issue doesn't happen with Toolbar add button, which generates the Add dialog box and everything seems to be fine.

Also I have a unique ID associated with Task table (other than the TaskID generated by the sycnfusion gantt controll).  Reason for having this is I have project records which meant to have individual tasks and I need a way to distinguish tasks (have a foreign key - ProjectID) along with ID autonumber primary key on Task table.  Every time I add a new Task is there a way to pass these parameters (ProjectID & ID) back into Task records in Gantt control?  After inserting a new task if I try to update only ID I can get is TaskID and it can be a duplicate TaskID from another Project.

Regards
Prasanth

Attachment: ProjectGantt_383541eb.zip

Dinesh Kumar Nagarathinam [Syncfusion]
Replied On December 14, 2015 03:44 PM UTC

Hi Prasanth,

Query 1 : if I click "Add Above" on Task 2,  There is a new record created with Task 3 but Task 2's Id is updated to 3 also.  So I end up having 2 Tasks with same ID.  

Solution : We have added a new task above to the selected row, using context menu also using public methods but we are not able to reproduce this issue. Can you please revert us by modifying the below attached sample based on the reported issue along with replication procedure?

Query 2 : Every time I add a new Task is there a way to pass these parameters (ProjectID & ID) back into Task records in Gantt control?

Solution: Do you want to send additional parameters to server method? If so, We can pass additional parameters to the server method using Ajax Post.

Code Snippet:

[cshtml]


<script type="text/javascript">


function ActionComplete(args) {

            //...

var data = JSON.stringify({

                    'Task': ganttRec,

                    'ProjectID': 8, //Set the Project ID

                    'ID': ganttRec.TaskId,

                });

                $.ajax({

                    type: "POST",

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

                    data: data,

                    contentType: 'application/json',

                });

           //...     

 }

</script>


[CS]


[HttpPost()]

        public void Add(TaskData Task, int ProjectID, int ID)

        {        

             //...

        }




We have prepared a sample based on above queries, find the sample from below location.

Sample: http://www.syncfusion.com/downloads/support/forum/121423/ze/Gantt-1472000357

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

Regards,

Dinesh kumar.N


Prasanth
Replied On December 18, 2015 04:21 AM UTC

Hi Dinesh,

Thanks for your reply and sample code.  I think I didn't explain properly with previous message also my understanding of how Gantt  wasn't perfect.  

My requirement is that we have Projects and each project will have it's own Gantt chart therefore it is likely to have repeated auto generated Task ID overall in the database.  So I have ended up creating ID which is auto incremented column in the database along with project id and Task Id (which is generated by the Gantt control).

I have also narrowed down the order of events firing while updating and adding new records.  I have attached a sample solution (VS 2015, Syncfusion 13.3.0.7, MVC5) along with this reply.  In the sample solution we have Parent Task 1 which as Child Task 1 and Parent Task 2 which has Child Task 2.

  1. If I Add new Task (e.g by Clicking the + button on tool bar or using the Menu Add Above/Below) then couple of events are being fired
  • Update event (which has correct data including Resource list) for the newly added task even though this task has never existed before then (some times before this step additionally update method is also called using Parent Task 1 object).
  • Add event (with all the correct data filled in the view model object)
Now this is not an big issue as I can ignore further method(s) calling as ID doesn't exist I know that this is an object that needs to be added first. 
  1. If I update Child Task 1
  • Update event is fired using the Parent Task view model object twice then - this can be ignored or no issue with updating twice I suppose
  • Update event is fired using the Child Task view model, however I have noticed here there is an issue with Resource List -> Resource length seems to be correct but however the resource list seems to be empty i.e. all the id values are set to 0.
This is an issue as I am seems to be losing resources being set.

If you could have a look at this issue that would be greatly appreciated.  Sorry for sending this through on Friday

Regards
Prasanth

    Attachment: Resources_a281d854.zip

    Dinesh Kumar Nagarathinam [Syncfusion]
    Replied On December 18, 2015 12:48 PM UTC

    Hi Prasanthan,

    Query 1 : Update event (which has correct data including Resource list) for the newly added task even though this task has never existed before then (some times before this step additionally update method is also called using Parent Task 1 object).

    Solution : We have resolved this issue in our latest Syncfusion version 13.3.0.18, we have request you to update your version. You can download the latest version from below link.

    Link : http://www.syncfusion.com/forums/121314/essential-studio-2015-volume-3-service-pack-2-release-v13-3-0-18-available-for-download

    Query 2 :  Update event is fired using the Child Task view model, however I have noticed here there is an issue with Resource List.

    Solution : The Item Collection which is from “ActionComplete” client side event includes only the defined fields in data source (in your sample, fields in ProjectTaskViewModel). If we want complete Resource collection of particular record then we can get it from “args.data.resourceInfo”, for more information find the following code snippet.

    Code Snippet:

    <script type="text/javascript">               

            function ActionComplete(args) {

        //args.data contains all datas of particular task..

          var  data = args.data.item;

        //Resource Details of the task.

           var  resource = args.data.resourceInfo

    }

    </script>


    Query 3 : Resource length seems to be correct but however the resource list seems to be empty i.e. all the id values are set to 0.

    Solution : We have analyzed your attached sample and noticed that you are defining the database ID field in ProjectTaskViewModel, but you never assign any value for the ID field while defining the Gantt datasource (in GanttData class).

    We have prepared a sample with auto increment ID in SQL data table with above your requirements, find the sample from below location.

    Sample : http://www.syncfusion.com/downloads/support/forum/121423/ze/MVCsampleSQL-2080498500

    Please let us know, if you need further assistance on this.

    Regards,
    Dinesh kumar.N


    Prasanth
    Replied On December 20, 2015 12:31 PM UTC

    Hi Dinesh,

    Thanks for the solution and information.  I have migrated to 13.3.0.18.  

    With the new solution Update method has additional parameter for passing on resource list information.  However I still noticed that update method is called for parent task as well, though it's not a major issue.  However is it possible for you to provide code snippet for achieving (including the ability to save the resource list) this for newly added task.  

    I have tried something like below but no success, resource list seems to be null on server/controller side add method

    var ganttRec = args.addedRecord.item;
                    var data = JSON.stringify({
                        'task': ganttRec,
                        'resources': args.addedRecord.resourceInfo //Resource Details of the task.
                    });

    $.ajax({
                        type: "POST",
                        url: "/Gantt/Update",  //Update is Server side method
                        data: data,
                        traditional: true,
                        contentType: 'application/json'
                    });


    Also another question regarding Gantt chart.  It seems the Parent resource list is not editable i.e. if task has child task then parent task is mostly non-editable.  I can understand the reason for locking most of the fields but, if you have resource setup for a task but then decided to add child tasks then parent's tasks might need to change.

    Regards
    Prasanth 


    Regards
    Prasanth

    Dinesh Kumar Nagarathinam [Syncfusion]
    Replied On December 21, 2015 10:19 AM UTC

    Hi Prasanth,

    Query 1 : However I still noticed that update method is called for parent task as well, though it's not a major issue.

    Solution : It is default behavior of the Gantt, whenever we update the duration or progress field of any child task, the parent task of the corresponding child task should be updated as per the child task’s updated field values. For your clear understanding, instead of editing a task with edit dialog box, edit a particular cell by doing double click on them. If we change the duration field alone then the parent task will update because the changes will affect the parent task. If we change the “Task Name” field alone the parent task will not be affected because this field has not any impact with parent task.

    Query 2 :  However is it possible for you to provide code snippet for achieving (including the ability to save the resource list) this for newly added task.  

    Solution : We request you to set the name of resource id field same for both TaskData and Resources Datasources.

    Code Snippet:

    [CS]

    // Gantt Data Fields

    public class TaskData

        {

            public string TaskId { get; set; }

            public string TaskName { get; set; }

                    //...

           public List<int> ResourceID { get; set; }

                    //...


        }

    // Resource Data Fields

    public class myDropDown

        {

            public string ResourceID { get; set; }      

            public string ddtext { get; set; }

        }


    [CSHTML]

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

           TaskIdMapping("TaskId").

                    //...


               //To Set the resources


    ResourceInfoMapping("ResourceID").// "Resource" which is defined in Gantt data object

    ResourceIdMapping("ResourceID").//"ResourceID" which is defined in Resource datasource

    ResourceNameMapping("ddtext"). //"ddtext" which is defined in Resource datasource.


                    //...


    )


    We have prepared a sample based on your above requirement, find the sample from below location.

    Sample : http://www.syncfusion.com/downloads/support/forum/121423/ze/Add_New_Task_with_Resource_List1297134513

    Query 3 : Also another question regarding Gantt chart. It seems the Parent resource list is not editable.

    Solution : We can edit the Resource list of parent task with cell editing. Now we have noticed that we cannot edit the parent resource list with edit dialogue box and consider this is an issue, so we have logged an issue 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.

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

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

    Regards,

    Dinesh kumar.N


    Prasanth
    Replied On December 22, 2015 07:42 AM UTC

    Hi Dinesh,

    Thanks for the reply.  Sorry about the inquiry again.  I have noticed that the sample provided regarding query 2 only handles Update of Task.  The solution for update action was already provided by you earlier.  I was after Add action where I was having trouble with saving / passing in resource list.

    e.g. on javascript / Ajax side with in the function ActionComplete(args)

    function ActionComplete (args){
        if (args.requestType === 'save' && args.addedRecord){
            //how do I call the controller method to pass in resource list assigned to the new task, so I can save the new task and resources associated with the task
        }
    }

    Regards
    Prasanth

    Dinesh Kumar Nagarathinam [Syncfusion]
    Replied On December 23, 2015 12:34 PM UTC

    Hi Prasanth,

    We can save the newly added task to SQL database using AJAX post method in “ActionComplete” client side event. Please find the code snippet from below,

    Code Snippet :

    [CSHTML]


    <script type="text/javascript">      

            function ActionComplete(args) {

                if (args.requestType === 'save' && args.addedRecord) {

                    addedItem = args.addedRecord.item;

                    var addedRecord = JSON.stringify({

                        'Task': addedItem,

                        'Resource': args.addedRecord.resourceInfo

                    });

                    $.ajax({

                        type: "POST",

                        url: "/Gantt/Add",//Add is Server side method

                        data: addedRecord,

                        traditional: true,

                        contentType: 'application/json'

                    });

                }

    </script>


    [CS]


            [HttpPost()]

            public void Add(GanttData Task, List<myDropDown> Resource)

            {

               

                //Using INSERT Query to add the New Record to SQL Table

            }



    We have prepared a sample based on your requirement, find the sample from below location.

    Sample: http://www.syncfusion.com/downloads/support/forum/121423/ze/MVCsampleSQL1469588783

    Please let us know, if you need further assistance on this.

    Regards,

    Dinesh kumar.N


    Prasanth
    Replied On December 24, 2015 05:12 AM UTC

    Hi Dinesh,

    Thanks for the reply and source code.  I had tried something similar before (since you had provided the update controller code) and previously it didn't work.  However, now your code seems to be working at the moment for new add functionality.  So I will use your code as a template and fix the code.  Thanks again for the source code and helping me out.

    Wishing you a Merry Christmas and a Happy New Year

    Regards
    Prasanth

    Dinesh Kumar Nagarathinam [Syncfusion]
    Replied On December 24, 2015 12:21 PM UTC

    Hi Prasanth,
    Thanks for your update.
    please let us know if you need further assistance on this.
    Syncfusion wishes you a Merry Christmas and a Happy New Year.
    Regards,
    Dinesh kumar.N

    CONFIRMATION

    This post will be permanently deleted. Are you sure you want to continue?

    Sorry, An error occured while processing your request. Please try again later.

    Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

    ;