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

Using jQuery.getJSON to fill dataSource

3 Answers 292 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 10 Oct 2011, 05:18 PM
Hi,

I am programming a MVC3 project and using jQuery to retrieve data. While working on this I stumbled upon the following issue. I'll post a code sample to illustrate this:

jQuery.getJSON("@Url.Action("DashboardData", "Dashboard")", function(ds) {
    $("#projectStateChart").kendoChart({
        theme: "black",
        title: { text: "" },
        legend: { position: "right" },
        dataSource: { data: ds.SummaryDataSource },
        series: [{ type: "pie", field: "Count", categoryField: "State", startAngle: 160, padding: 0 }]
    }).data("kendoChart");
     
    $("#outputText").text(ds.SummaryDataSource);
});

As you can see I am fetching data from a Action. This works well as the #outputText is showing well formatted JSON. When copying this text and pasting in the code above I get a perfectly working graph. But when using "data: ds.SummaryDataSource" (which should be the same) it is not working. How can I convert the string ds.SummaryDataSource to a KendoUI DataSource?

Thanks in advance!

Best regards,
Peter

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Oct 2011, 08:29 AM
Hello Peter,

Could you please provide more info about the structure of the JSON return form the request?

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
raj
Top achievements
Rank 1
answered on 17 Oct 2011, 04:29 PM
Hi
    Im also facing the same issue as mentioned..

I used jQuery.getJSON("ControllerName/MethodName",function (data){

$("#projectStateChart").kendoChart({
        theme: "black",
        title: { text: "" },
        legend: { position: "right" },
        dataSource: { data: ds.SummaryDataSource },
        series: [{ type: "pie", field: "Count", categoryField: "State", startAngle: 160, padding: 0 }]
    }).data("kendoChart");

}

In my controller method i have
Public ActionResult MethodName()
{
return JSON(ModelClass.MyData);

}


The controller method gets fired but i don see any graph..

Please help Telerik Team
0
Rosen
Telerik team
answered on 18 Oct 2011, 11:47 AM
Hi Raj,

As I have mentioned in my previous message, information about the actual structure of the JSON result will be appreciated.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Peter
Top achievements
Rank 1
Answers by
Rosen
Telerik team
raj
Top achievements
Rank 1
Share this question
or