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

Kendo line chart

3 Answers 56 Views
Sample Applications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Suk
Top achievements
Rank 1
Suk asked on 18 Mar 2015, 01:20 PM
Hello,
I have a kendo grid and below it is a kendo line chart.

Based on the grid I need to build the chart as they are inter- related.(and made from the same data)

So, can I use the same controller method for both??

.Read(read => read.Action("GetResults", "home").Data("GetInputData"))

My controller method (basically first made for grid),

 public ActionResult GetFuturePrices([DataSourceRequest]DataSourceRequest request, String Name, String Address)
        {
            List<Details> DetailsList = new List<Details>();
            //something something...
            return Json(DetailsList .ToDataSourceResult(request), JsonRequestBehavior.AllowGet);         
        }

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 23 Mar 2015, 11:07 AM
Hello,

By default the DataSources of the Chart and the Grid MVC wrappers expect a different response. The Grid DataSource expects a DataSourceResult and the Chart DataSource expects the collection to be returned directly. It is possible however to use the same action to load the data by using the Custom builder for the Chart DataSource to specify that the data should be loaded from a field with named "Data" e.g.
Html.Kendo().Chart<MyModel>()
    .DataSource(dataSource=> dataSource
        .Custom()
        .Schema(schema => schema
            .Data("Data")
        )
        .Transport(transport => transport
            .Read(read => read.Action("GetResults", "home").Data("GetInputData").Type(HttpVerbs.Post))
        )
    )


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Suk
Top achievements
Rank 1
answered on 24 Mar 2015, 10:37 AM
Thank you for your response... I understood the difference between the responses for grid and chart...
So, I had to create two different controller methods, one passing with `ToDataSourceResult()` for grid and for chart just passing the list (collection)... And its working fine...Problem solved...

But still, I am unclear about the `.Data("Data")` part... Could you please kindly elaborate...
0
Daniel
Telerik team
answered on 27 Mar 2015, 07:52 AM
Hello again,

Please refer to this documentation topic for information about the schema data option.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Sample Applications
Asked by
Suk
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Suk
Top achievements
Rank 1
Share this question
or