I am trying to use a ASP.NET Webservice with KendoUI Datasource. For example:
The problem is that the json being returned is:
Note the quote after the d:
This is being added by the Webservice because I am using Newtonsoft.Json.JsonConvert.SerializeObject to create the json. I am using Newtonsoft because I have not found a was to serialize a generic List object.
So the question is:
1. How do I get DataSource to work with the quoted results?
or
2. How do I get the webservice to not to quote the results?
The Webservice code is:
Please help. (I've been tearing my hair out for two days on this).
-George
$("#grid").kendoGrid({ dataSource: { data:airports, schema: { data: 'd' } }, columns: [ { field: "airportName", }, { field: "airportCode" } ]});The problem is that the json being returned is:
d: "[{"airportName":"BDL:Bradley International Airport, CT","airportCode":"BDL"},{"airportName":"HVN:Tweed New Haven Regional Airport, CT","airportCode":"HVN"},{"airportName":"EWR:Newark Liberty Intl, NJ","airportCode":"EWR"},{"airportName":"HPN:Whiteplains Airport,NY","airportCode":"HPN"},{"airportName":"JFK:John F. Kennedy Intl,NY","airportCode":"JFK"},{"airportName":"LGA:La Guardia Airport,NY","airportCode":"LGA"}]};"Note the quote after the d:
This is being added by the Webservice because I am using Newtonsoft.Json.JsonConvert.SerializeObject to create the json. I am using Newtonsoft because I have not found a was to serialize a generic List object.
So the question is:
1. How do I get DataSource to work with the quoted results?
or
2. How do I get the webservice to not to quote the results?
The Webservice code is:
[WebMethod()]public string GetAirportList(){ List<Airport> Airports = new List<Airport>(); Airports.Add(new Airport { airportCode = "BDL", airportName = "BDL:Bradley International Airport, CT" }); Airports.Add(new Airport { airportCode = "HVN", airportName = "HVN:Tweed New Haven Regional Airport, CT" }); Airports.Add(new Airport { airportCode = "EWR", airportName = "EWR:Newark Liberty Intl, NJ" }); Airports.Add(new Airport { airportCode = "HPN", airportName = "HPN:Whiteplains Airport,NY" }); Airports.Add(new Airport { airportCode = "JFK", airportName = "JFK:John F. Kennedy Intl,NY" }); Airports.Add(new Airport { airportCode = "LGA", airportName = "LGA:La Guardia Airport,NY" }); return Newtonsoft.Json.JsonConvert.SerializeObject(Airports);}Please help. (I've been tearing my hair out for two days on this).
-George