DataSource Schema "data" property

6 posts, 0 answers
  1. Andrew
    Andrew avatar
    20 posts
    Member since:
    Jun 2012

    Posted 12 Apr 2013 Link to this post

    I'm initialising a chart in MVC razor syntax, and am unable to find a way of specifying the schema of returned data from an AJAX bound DataSource, as specified in the DataSource documentation:

    schema: {
        data: "results" // twitter's response is { "results": [ /* results */ ] }
    }

    As I'm not autobinding my chart, I've tried setting the schema property in JS before calling the read() method on the DataSource , but this doesn't seem to make any difference:

    chart.dataSource.options = { schema: { data: "results" } };

    Is this functionality possible using the ASP.NET wrappers?
  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 16 Apr 2013 Link to this post

    Hello,

    The DataSource schema will be generated automatically from the specified model class. You can specify the model class as a generic argument:

        @(Html.Kendo().Chart<ElectricityProduction>()
             .Name("chart")
             .DataSource(ds => ds.Read(read => read.Action("_Read", "Home")))
             ...


    I hope this helps.

    All the best,
    Tsvetomir Tsonev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Orrin
    Orrin avatar
    4 posts
    Member since:
    Dec 2013

    Posted 02 Jan 2014 Link to this post

    I have the same question and can't rely on the auto-bind.  How would I map the data property to Mymodel.ChildCollection?
  5. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 06 Jan 2014 Link to this post

    Hello Orrin,

    Setting the schema explicitly is not supported via the MVC wrappers. The raw JS API might make more sense in your case.

    Do you mind sharing a bit more details about your setup?

    Regards,
    T. Tsonev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 06 Jan 2014 Link to this post

    Hi,

    Just a quick follow-up. You can also try passing the collection to the constructor:

        @(Html.Kendo().Chart(Mymodel.ChildCollection)

    I hope this helps.

    Regards,
    T. Tsonev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Orrin
    Orrin avatar
    4 posts
    Member since:
    Dec 2013

    Posted 07 Jan 2014 Link to this post

    Okay, thanks.  I had a complex model I wanted to bind to my form (parent with child collection), which I've since learned KendoUI doesn't support.  I've broken my view model into separate models for each level of the hierarchy as suggested in other posts.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready