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
close icon

Add data to Gantt MVC 5 , being able to send all gantt data back to controller using ajax call

Hi I notice if I add a new record to Gantt and select a resource , resource is not added if I edit record and select resource and add then it is displayed,

I urgently need information on how to get resource selection back to controller (all gantt data) I have looked at you java-script actioncomplete function
I need to get complete Gantt record back to controller so that I can save it to sql database, the saving is not the problem but getting it back to controller I am using
MVC 5 and

        <add assembly="Syncfusion.Compression.Base, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.EJ, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.EJ.Mvc, Version=13.3500.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.Linq.Base, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.XlsIO.Base, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.EJ.Olap,Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
        <add assembly="Syncfusion.Olap.Base, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />

Regards


Edmund Herbert

10 Replies

DK Dinesh Kumar Nagarathinam Syncfusion Team December 17, 2015 12:33 PM UTC

Hi Herbert,

Query : Hi I notice if I add a new record to Gantt and select a resource , resource is not added if I edit record and select resource and add then it is displayed,

Solution : We request you to set the name of resource id field same for both TaskData and Resources Datasources. Also make sure with the column name of SQL table and Entity Framework Table.

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.


                //...


)


Query : I urgently need information on how to get resource selection back to controller (all gantt data) I have looked at you java-script actioncomplete function
I need to get complete Gantt record back to controller so that I can save it to sql database, the saving is not the problem but getting it back to controller.

Solution : We can get the complete Gantt Data from parameters (args.data.item) of ActionComplete client side event, in this item collection for resource reference we have passed the Resource ID alone, if we want complete resource details of a particular gantt record then we can get it by args.data.resourceInfo.

Code Snippet:

<script type="text/javascript">  

function ActionComplete(args) {


//Complete Gantt Data Details.

var GanttData = args.data.item,

//Complete Resource Details of particular Gantt Record.

    ResourceDetail = args.data.resourceInfo;

}

</script>


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

Sample: http://www.syncfusion.com/downloads/support/forum/121460/ze/Mvc5GanttSample1404533793

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

Regards,

Dinesh kumar.N



EH Edmund Herbert December 17, 2015 01:41 PM UTC

Thank you very much your support is outstanding

Regards

Edmund Herbert


EH Edmund Herbert December 17, 2015 05:19 PM UTC

Hi Dinesh

I did some tests on id one i set the start date and time and end date and time i noticed that the start time was out by 2 hours

please have a look at attached project

Regards

Edmund Herbert

Attachment: Mvc5GanttSample_193ea2ab.rar


EH Edmund Herbert December 17, 2015 06:22 PM UTC

Hi Guys my fault you save date as UCT then browser applies local in my case adds 2 hours

Anyway

Thanks for your excellent service

Regards

Edmund


DK Dinesh Kumar Nagarathinam Syncfusion Team December 18, 2015 05:04 AM UTC

Hi Herbert,

Thanks for your update.

Please let us know, if you need further assistance on this.
Reagrds,
Dinesh kumar.N



EH Edmund Herbert December 22, 2015 12:22 AM UTC

Hi Dinesh

I note that in your example if I add a new record then in the controller the add as well as the update functions are called is this correct, I thought if adding then only the add function would be called

also how would i deal with a delete call

Regards Edmund


MK Mahalakshmi Karthikeyan Syncfusion Team December 22, 2015 01:02 PM UTC

Hi Edmund,

Query1: I note that in your example if I add a new record then in the controller the add as well as the update functions are called is this correct, I thought if adding then only the add function would be called

Solution: We can also reproduce the behavior as reported, the ActionComplete requestType “recordUpdate” will trigger for newly added row also in the Essential studio version 13.3.0.7. But we have changed this behavior to trigger ActionComplete only once with requestType as “save” for newly added row in our latest Essential studio version 13.3.0.18. We recommend you to upgrade to this version to overcome this issue.

Query2: also how would i deal with a delete call

Solution: we can also delete the selected row to the data base with the help of ActionComplete requestType as “delete”. Please refer the below code example for details.

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

//…

  ClientSideEvents(eve=>{

          eve.ActionComplete("ActionComplete");         

      }).

)

<script type="text/javascript">              

        function ActionComplete(args) {

//…

        if (args.requestType === 'delete') {

                var deletedRecord = args.data.item;

                $.ajax({

                    type: "POST",

                    url: "/TreeGrid/Delete"//Update is Server side method

                    data: deletedRecord,

                });

            }

        }        

</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/general/ze/Mvc5GanttSample1154052449

Regards,

Mahalakshmi K.



EH Edmund Herbert December 22, 2015 07:44 PM UTC

Hi Mahalakshmi

The example that you sent me is a workaround and technically fails because when adding a new record the update record event can and does sometimes fire first and then you code fails

I have sent other reports of this even mix-up  update event fires on add and update when are you going to fix problem

This is now very urgent please

Regards
Edmund Herbert





EH Edmund Herbert December 22, 2015 07:46 PM UTC

ok the fix is to upgrade to .18 version i will try this


DK Dinesh Kumar Nagarathinam Syncfusion Team December 23, 2015 12:38 PM UTC

Hi Edmund,

Thanks for your update.

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

Regards,

Dinesh kumar.N


Loader.
Live Chat Icon For mobile
Up arrow icon