I want to show the poll result for a specific survey question. When I clicked the list of questions, I want to associate my chart with the query according to the selected question.
So my plan was; 1. Get the questionId from the selected question line. this is normal.
ClientEvents.OndataBinding event definition in my diagram. So I could pass questionId with;
function onChartDataBinding (e) {e.data = $ .extend (e.data, {questionId: questionId}); }
using $('#ChartPollResults').data('tChart').rebind(); in the selected question list grid event.
This script works when I have a second grid snap according to the first grid of the selected row. But there seems to be no ClientEvents.OnDataBinding event to manage the chart. And the " rebind() " method is not supported in the chart control.
The chart code used is below.
@(Html.Telerik().Chart<QuestionResult>() .Theme("WebBlue") .Name("ChartPollResults") .Title("Poll Question Choice Number vs. Choice Count") .Legend(legend => legend.Position(ChartLegendPosition.Bottom)) .Series(series => { series.Bar("ChoseCount").Name("Choice Count").Gap(5); }) .CategoryAxis(axis => axis.Categories(o => o.ChoiceNumber)) .DataBinding(dataBinding => dataBinding.Ajax().Select("_PollResultChartBinding", "Poll", new { questionId = 0 })) .HtmlAttributes(new { style = "width: %100px; height: 270px" }) )
Binding Method My Controller;
public ActionResult _PollResultChartBinding(int questionId = 0) { //questionId = 3; if (!ModelState.IsValid || questionId == 0) return Json(new List<QuestionResult>()); PollQuestionDefinition pollQuestion = service.Get(questionId); List<PollAnswer> pollAnswers = service.GetPollAnswersByQuestion(questionId); PollQuestionResultUI result = new PollQuestionResultUI(pollQuestion, pollAnswers); return Json(result.Results); }
When I comment on the line //questionId = 3; , I can easily see the results for the question wiht Id = 3 in the diagram.
But I can not pass the questionId to the chart.
Thanks in advance.
source share