- Home
- Forum
- ASP.NET MVC (Classic)
- How to refresh a chart with callbacks
How to refresh a chart with callbacks
We need to refresh the chart datasource when changing the selected values on comboboxes. I don't want to reload the page. I just need to relaod/replace the partial view where the chart is.
Thanks,
Julien
Thanks for using Syncfusion products.
We suggest you to use Ajax to avoid reload the page when selected values on combo boxes. Please refer the attached sample for this query.
Please us know if you have any concern.
Regards,
Vijayabharathi
Sample_9ece8876.zip
We're going with another approach to doing our AJAX, and that is the controller returns a JSON object with the generated HTML string, which Javascript will insert it directly into the page.
My question is how do I generate the HTML string within the Controller. In the View, we use something like:
Html.Syncfusion().Chart("chart_Model", (MVCChartModel)ViewData["ChartModel"])
But this doesn't compile if I put this in the Controller. It doesn't recognize the first Html class/namespace. What is the equivalent syntax I can use?
Thanks!
Hi
Julien,
Thanks
for the update.
If
your intention is to use html helper in controller means, you can use the below
code snippet in controller for chart to achieve this,
[C#]
MVCChartModel chartModel = new MVCChartModel();
InitializeChart(chartModel);
ViewData["ChartModel"]
= chartModel;
//html helper in controller
System.IO.TextWriter
writer = new System.IO.StringWriter();
var html = new HtmlHelper(new ViewContext(ControllerContext,
new WebFormView(ControllerContext,
"Index"), new
ViewDataDictionary(), new TempDataDictionary(),
writer), new ViewPage());
var
ChartString = html.Syncfusion().Chart("Chart_Model",
chartModel);
Also, please
refer the below forum links to know more details for this,
http://stackoverflow.com/questions/6887697/htmlhelper-in-controller
http://stackoverflow.com/questions/621235/using-htmlhelper-in-a-controller
Please let us
know if we misunderstood your query.
Regards,
Vijayabharathi
- 3 Replies
- 3 Participants
-
MO Montani
- Nov 11, 2011 10:05 AM UTC
- May 23, 2012 07:35 AM UTC