or
01.var dataSource = new kendo.data.DataSource({02. type: "odata",03. transport: {04. read: {05. url: listUrl,06. type: "GET",07. dataType: "json",08. contentType: "application/json;odata=verbose",09. headers: {10. "accept": "application/json;odata=verbose"11. }12. },13. create: {14. url: listUrl,15. type: "POST",16. dataType: "json",17. contentType: "application/json;odata=verbose",18. headers: {19. "accept": "application/json;odata=verbose",20. "X-RequestDigest": $("#__REQUESTDIGEST").val(),21. }22. },23. update: {24. url: function (data) {25. return listUrl + "(" + data.ID + ")";26. },27. beforeSend: function (jqXhr, options) {28. 29. var data = JSON.parse(options.data);30. 31. jqXhr.setRequestHeader("If-Match", data.__metadata.etag);32. 33. },34. type: "POST",35. dataType: "json",36. contentType: "application/json;odata=verbose",37. headers: {38. "accept": "application/json;odata=verbose",39. "X-RequestDigest": $("#__REQUESTDIGEST").val(),40. "X-HTTP-Method": "MERGE"41. },42. },43. destroy: {44. url: function (data) {45. return listUrl + "(" + data.ID + ")";46. },47. type: "DELETE",48. dataType: "json",49. contentType: "application/json;odata=verbose",50. headers: {51. "accept": "application/json;odata=verbose",52. "X-RequestDigest": $("#__REQUESTDIGEST").val(),53. "X-HTTP-Method": "MERGE",54. "If-Match": "*"55. }56. }57. },58. pageSize: 20,59. schema: {60. data: "d.results",61. model: {62. id: "ID",63. fields: {64. ID: { editable: false, nullable: false },65. Title: { validation: { required: true } },66. Body1: { validation: { required: true } },67. Votes: { type: "number", validation: { required: true, min: 1 } },68. }69. }70. }71. });<string xmlns="http://yaddayaddayadda.com/"> [{"title":"Stuff","value":"Here's some stuff"}]</string>[WebService(Namespace = "http://yaddayaddayadda.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [ScriptService] public class websiteWebService : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetStuff(int stuff_id) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["stuff"].ConnectionString); connection.Open(); SqlCommand command = new SqlCommand("o_get_stuff", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@stuff_id", stuff_id); SqlDataReader dr = command.ExecuteReader(); DataTable dt = new DataTable("Stuff"); dt.Load(dr); dr.Close(); connection.Close(); List<Dictionary<string, object>> rows = new
List<Dictionary<string, object>>(); Dictionary<string, object> row = new
Dictionary<string, object>(); foreach (DataRow datarow in dt.Rows) { row = new Dictionary<string, object>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, datarow[col]); } rows.Add(row); } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonData = serializer.Serialize(rows); return jsonData; } }}<script type="text/javascript"> $(document).ready(function () { $("#stuffSelector").kendoDropDownList({ dataTextField: "title", dataValueField: "value", dataSource: { transport: { read: { contentType: "application/json", type: "POST", url: "http://localhost:23035/Services/websiteWebService.asmx/GetStuff", data: { stuff_id: "0" } } } } }); }); </script>