This is a migrated thread and some comments may be shown as answers.

DataSource Schema "data" property

5 Answers 176 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 2
Andrew asked on 12 Apr 2013, 11:07 AM
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?

5 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 16 Apr 2013, 07:37 AM
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!
0
Orrin
Top achievements
Rank 1
answered on 02 Jan 2014, 08:57 PM
I have the same question and can't rely on the auto-bind.  How would I map the data property to Mymodel.ChildCollection?
0
T. Tsonev
Telerik team
answered on 06 Jan 2014, 04:05 PM
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!
0
T. Tsonev
Telerik team
answered on 06 Jan 2014, 04:11 PM
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!
0
Orrin
Top achievements
Rank 1
answered on 07 Jan 2014, 05:27 PM
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.
Tags
Chart
Asked by
Andrew
Top achievements
Rank 2
Answers by
T. Tsonev
Telerik team
Orrin
Top achievements
Rank 1
Share this question
or