Hi,
I'm having some trouble binding a KendoUI chart to a remote database through a web service.
Here is my code:
and here is the web service code:
I've verified that my webservice returns a complete dataset.
The problem is that when I run the code, the chart doesn't get populated. There are no error messages and no events fired in the event log.
The only issue I can find is that the webservice returns the data with leading a trailing quotes, like this:
"[{"Code":"1301","Count":239},{"Code":"1401","Count":178},{"Code":"1001","Count":33}]"
When I copy the data returned from the web service into a .json file and bind the chart to that, it works fine. However, I have to remove the leading and trailing quotes to get it to work.
How can I get my webservice to return my data in proper JSON format?
Thanks.
I'm having some trouble binding a KendoUI chart to a remote database through a web service.
Here is my code:
$("#chart").kendoChart({ theme: $(document).data("kendoSkin") || "default", dataSource: { transport: { read: { url: "/WebServices/WebFunctions.asmx/RetrieveProjectCountByBMP", dataType: "json" } }, schema: { model: { fields: { Code: { type: "string" }, Count: { type: "number" } } } }, sort: { field: "Code", dir: "asc" } }, title: { text: "Project Count by BMP" }, seriesDefaults: { type: "column" }, series: [{ field: "Count", name: "Project Count" }], categoryAxis: { field: "Code" }, tooltip: { visible: true, format: "{0:N0}" }});and here is the web service code:
<WebMethod(EnableSession:=True)> _Public Function RetrieveProjectCountByBMP() As Object Dim returnData = (From p As Project In Project.RetrieveAll() _ Join cs As ClaimScope In ClaimScope.RetrieveAll() On p.ProjectId Equals cs.ProjectId _ Join b As BMP In BMP.RetrieveAll On cs.BMPId Equals b.BMPId _ Where (p.ProjectMilestoneId = 17 Or p.ProjectMilestoneId = 18 Or p.ProjectMilestoneId = 19) _ And p.FiscalyearId = 5 _ Select b.Code, p.ProjectId).GroupBy( _ Function(bmpCode) bmpCode.Code _ , Function(proj) proj.ProjectId _ , Function(bmpCode, projects) New With {.Code = bmpCode, .Count = projects.Count()}) Dim serializedReturnData As JavaScriptSerializer = New JavaScriptSerializer(returnData) Return serializedReturnData.Serialize(serializedReturnData) Return serializedReturnDataEnd FunctionI've verified that my webservice returns a complete dataset.
The problem is that when I run the code, the chart doesn't get populated. There are no error messages and no events fired in the event log.
The only issue I can find is that the webservice returns the data with leading a trailing quotes, like this:
"[{"Code":"1301","Count":239},{"Code":"1401","Count":178},{"Code":"1001","Count":33}]"
When I copy the data returned from the web service into a .json file and bind the chart to that, it works fine. However, I have to remove the leading and trailing quotes to get it to work.
How can I get my webservice to return my data in proper JSON format?
Thanks.