Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Chart > Ajax binding to a complex type

Not answered Ajax binding to a complex type

Feed from this thread
  • Posted on May 23, 2012 (permalink)

    I've been using the chart control in server binding mode for awhile, but now I have a need to use Ajax binding on a specific page.
    In server binding, I bind to a complex type called a UIReport.  A UIReport is a representation of an actual chart with a collection of UIDataSeries. The UIDataSeries types contain the chart type that should display the data, the data values for the series, and the series name, among other values.

    In server binding mode, I've been using the following approach, because I need to choose the chart type at run time:
    .Series(series =>
                {
                    foreach (var dataSeries in Model.Report.DataSeriesCollection)
                    {
                        switch (dataSeries.ChartType)
                        {
                            case ChartType.Area:
                                series.Area(dataSeries.Values).Name(dataSeries.Description);
                                break;
                            case ChartType.Bar:
                                series.Bar(dataSeries.Values).Name(dataSeries.Description);
                                break;
                            case ChartType.StackedBar:
                                series.Bar(dataSeries.Values).Name(dataSeries.Description).Stack(true);
                                break;
                            case ChartType.Column:
                                series.Column(dataSeries.Values).Name(dataSeries.Description);
                                break;
                            case ChartType.StackedColumn:
                                series.Column(dataSeries.Values).Name(dataSeries.Description).Stack(true);
                                break;
                            case ChartType.Line:
                                series.Line(dataSeries.Values).Name(dataSeries.Description);
                                break;
                            case ChartType.Pie:
                                series.Pie(dataSeries.Values).Name(dataSeries.Description);
                                break;
                        }
                    }
                })

    How should I approach this in Ajax binding?  What value should I use in the "foreach" at the top of the Series configuration, if indeed this is supported at all? I've looked at the Ajax sample and it seems more straightforward.

    My Ajax controller basically does something like this:
    UIReport myreport = GetUIReport();
    return new JSON(myreport);

    Thanks for any pointers.

    Chris



    Reply

  • Posted on May 23, 2012 (permalink)

    Looking into this more, I see that I should probably provide a List of my UIDataSeries out of the ContentResult that provides the Ajax data.  But, I'm still not seeing if it is possible to create a series of an indeterminant chart type based on data coming back from the json ajax query.
    Do you have to hook up the client event onDataBound and do this through javascript?

    thanks

    Reply

  • Petur Subev Petur Subev admin's avatar

    Posted on May 28, 2012 (permalink)

    Hello Chris,

    If I understand your scenario correctly you want to change the series types on the client. If so - I am afraid that this is not supported and your scenario cannot be easily work-arounded on the client.

    Greetings,
    Petur Subev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Chart > Ajax binding to a complex type
Related resources for "Ajax binding to a complex type"

ASP.NET MVC Chart Features  |  Documentation  |  Demos  |  Telerik TV ]