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

Refresh data from Gantt

I have a Gantt and want to load data depending from value selected on a combobox. In all of examples I saw the gantt data is loaded from the ViewBag.

So how can I refresh the data using a method on my MVC Controller to load the data, with no reload on page?

And how would be the property .DataSource on my view?

Regards,
Otto.

5 Replies

BM Bharath Marimuthu Syncfusion Team January 26, 2015 01:44 PM UTC

Hi Otto ,

Thank you for using Sycnfusion products.

Yes it is possible to refresh the datasource for the Gantt control without reloading the page . We have prepared a sample for refreshing the Gantt control with different datasource using the combobox selection changed event . Also the ‘.Datasource’ property of the Gantt control will be as an object and it can be retrieved using the below code snippet ,

Code snippet :

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

                  .TaskIdMapping("TaskID")

                  .ChildMapping("Children")

                  //...

                  .Datasource(ViewBag.datasource)

    )

   var data = $("#Gantt").data("ejGantt").model.dataSource;

Please find the sample in the below location .

Sample Location : http://www.syncfusion.com/downloads/support/directtrac/118044/MVC09NewSample-2058353859.zip

Please let us know if you need more information on this.

Thanks,

Bharath.




OM Otto Moura Machado Filho January 26, 2015 06:22 PM UTC

Thanks, it worked.

Now, when I "double-click" a column that I created I see a textbox to edit the value. I'd like to load a combobox, how can I do it?

Regards,
Otto Machado.


JR John Rajaram Syncfusion Team January 27, 2015 01:07 PM UTC

Hi Otto,

Thanks for the update.

We would like to let you know that, we can customize the column with combo box in Gantt control with the drop down data source.

1.     Using resourceInfoMapping property

Please refer the following code snippets for more details.

Code snippets:

In Index.cshtml:

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

                  .TaskIdMapping("Id")

                  .TaskNameMapping("Name")

                  //...

                  .ShowResourceNames(true)

                  .ResourceInfoMapping("Resources")

                  .ResourceNameMapping("Name")

                  .ResourceIdMapping("Id")

                  .Resources(ViewBag.resources)

                  .Datasource(ViewBag.datasource)

    )

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

  

In GanttController.cs:

namespace MVC09NewSample.Controllers

{

public class GanttController : Controller

    {

        //

        // GET: /Gantt/

        public ActionResult Index()

        {

            var DataSource = ResourceDataSource.GetData();

            ViewBag.datasource = DataSource;

            var Resources = ResourceList.GetData();

            ViewBag.resources = Resources;

            return View();

        }  

        public class ResourceList

        {

            public static List<ResourceListData> GetData()

            {

                List<ResourceListData> list = new List<ResourceListData>();

                list.Add(new ResourceListData() { Id = 1, Name = "Resource1" });

                list.Add(new ResourceListData() { Id = 2, Name = "Resource2" });

                list.Add(new ResourceListData() { Id = 3, Name = "Resource3" });

                list.Add(new ResourceListData() { Id = 4, Name = "Resource4" });

                list.Add(new ResourceListData() { Id = 5, Name = "Resource5" });

                list.Add(new ResourceListData() { Id = 6, Name = "Resource6" });

                list.Add(new ResourceListData() { Id = 7, Name = "Resource7" });

                return list;

            }

        }

        public class ResourceListData

        {

            public int Id { get; set; }

            public string Name { get; set; }

        }

        public class ResourceDataSource

        {

            public static List<ResourceData> GetData()

            {

                List<ResourceData> list = new List<ResourceData>();

                list.Add(new ResourceData()

                {

                    Id = 1,

                    Name = "Task 1",

                    StartDate = "02/23/2014",

                    //...

                    Resources = new List<int>() { 1, 2, 4, 5 },

                 //...

          }

        })

                });

         return list;

       }

  }

 

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

Sample: http://www.syncfusion.com/downloads/support/directtrac/118044/MVC09NewSampleResource812621839.zip

 

2.     Using “load” client side event.

At present we are facing some issues in editing custom column with combo box.  So we have logged an issue report “Issue in editing custom column with combo box”. The fix for the issue will be available in our upcoming service pack 2 release, which is expected to be out at the end of February 2015.

We would also like to inform you that, we can also provide a custom patch for this issue by February 17, 2014 if you are in need of a solution earlier.

Please refer the following code snippets for more details.

Code snippets:

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

                  .TaskIdMapping("Id")

                  .TaskNameMapping("Name")

                  //...

                  .ClientSideEvents(eve => {

                      eve.Load("load");

                  })

                  .Datasource(ViewBag.datasource)

    )

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

   <script type="text/javascript">

        //Data for DropDown

        var dropData = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"];

     function load(args)

        {

            var columns = this.getColumns();

            columns.splice(2, 0,

                {

                    field: "text",

                    headerText: "Product",

                    editType: "dropdownedit",

                    dropdownData: dropData,

                    width: "180px"

                });

        }

    </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/118044/MVC09NewSampleLoad230366319.zip

 

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

Regards,
John. R




OM Otto Moura Machado Filho January 27, 2015 04:18 PM UTC

There is no success on double-click to edit. In the example that you send me the double-click action don't select the value on combobox, it clears the value.

Is there a way to fix it?

Thanks,
Otto Machado.


JR John Rajaram Syncfusion Team January 28, 2015 09:34 AM UTC

Hi Otto,

We have already logged an issue report “Issue in editing custom column with combo box” and the same has been shared in the previous update. Now we have created incident "# 134550" for the better follow-up of this reported issue. Our support engineer will assist you through incident under your Direct Trac account.

Our Direct Trac support system can be accessed from the following link:

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

Regards,

John. R



Loader.
Live Chat Icon For mobile
Up arrow icon