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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Refresh gantt datasource on server side

Thread ID:

Created:

Updated:

Platform:

Replies:

118926 Apr 23,2015 08:51 PM UTC Apr 27,2015 10:37 AM UTC ASP.NET MVC 3
loading
Tags: Gantt
RobertS
Asked On April 23, 2015 08:51 PM UTC

Hi,

The webpage has a chart gantt and datepicker. When you change the date gantt chart should be refreshed with new content generated data source on the server side. 
How best to perform this operation avoiding unnecessary refresh the entire page?

Regards,
RobertS

John Rajaram [Syncfusion]
Replied On April 24, 2015 03:58 PM UTC

Hi Robert,

Thanks for using Syncfusion product.

We have analyzed your query and prepared a sample based on your requirement for updating the new datasource in Gantt control while changing the date in the ejDatePicker control without refreshing the browser.

Please refer the following code snippets for more details.

Code snippets:


<body>

@Html.EJ().DatePicker("DatePick").ClientSideEvents(s => s.Close("onClose"))

<br />


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


//...


.Datasource(ViewBag.datasource)


)

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


<script type="text/javascript">


var ganttData1=@Html.Raw(Json.Encode(ViewBag.dataSource)),

ganttData2=@Html.Raw(Json.Encode(ViewBag.dataSource1)),

flag=true;


function onClose(args) {

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

if(flag){

ganttObject.setModel({ dataSource: ganttData2 });

flag=false;

}

else{

ganttObject.setModel({ dataSource: ganttData1 });

flag=true;

}

}


</script>

</body>


Please find the sample in the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/118926/MVCsampleSQL90336456.zip

If this is not your exact requirement, we request you to share more details regarding your queries and revert to us by modifying our sample.

Please let us know if you have any questions about this.
Regards,
John R



RobertS
Replied On April 24, 2015 06:46 PM UTC

Hi, 

Thank you for your example. I found some other solution that works in a similar way but allows for more 
efficient communication with the controller. Anyway thanks for the suggestion.

....

              @(Html.EJ().DatePicker("startDate")
                    .Value(Model.Data.StartDate)
                    .ClientSideEvents(cs=>cs.Change("OnStartDateChanged"))

              @(Html.EJ().Gantt("gantt")
              // ...
              .Datasource(ViewBag.datasource)

....


        function OnStartDateChanged(args) {
            $.ajax("/Controller/RefreshData" { type: "POST", data: { date: args.value } })
              .done(function(result) {
                var ganttObject = $("#gantt").data("ejGantt");
                if (ganttObject) {
                    ganttObject.setModel({ dataSource: result.List.Data });
                }
              });
        }

Regards,
RobertS

Mahalakshmi Karthikeyan [Syncfusion]
Replied On April 27, 2015 10:37 AM UTC

Hi Robert,

Thanks for the update.

Yes, we can also refresh the Gantt data source in the Controller using AJAX post method.

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

Regards,

Mahalakshmi K.


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

;