Kendo line chart

4 posts, 1 answers
  1. Suk
    Suk avatar
    15 posts
    Member since:
    Mar 2015

    Posted 18 Mar 2015 Link to this post

    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);         
            }
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 23 Mar 2015 Link to this post

    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!
     
  3. Suk
    Suk avatar
    15 posts
    Member since:
    Mar 2015

    Posted 24 Mar 2015 in reply to Daniel Link to this post

    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...
  4. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 27 Mar 2015 Link to this post

    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!
     
Back to Top