I've built a function that loops through my data set and builds an array of the schema and detects what the data type is for each column (this is similar to excel in that it loops through the first few rows of data to determine its data type). This function returns an array that is similar structure to how the datasource schema is defined.
My problem is I cannot then figure out how to get this information into the data source configuration. calling the array directly into the datasource doesn't seem to work.
Below you can see I'm assigning the variable schema to another function that has a response similar to the one in the code block at the bottom of this post.
The full function is like so
01.function create_kendo_data_source(path, pagesize, rows_to_check_for_schema, callback) {02. if(pagesize == undefined) {03. pagesize = 20;04. 05. }06. 07. ajax_json_post(path, null, function(response) { //success08. var schema = create_kendo_data_source_schema(response);09. 10. console.log(schema);11. 12. var new_schema = {13. id: "data",14. fields: []15. 16. };17. 18. for(var i in schema) {19. var item = schema[i];20. 21. new_schema.fields.push({22. [item.column]: {23. type: item.type24. 25. }26. 27. });28. 29. }30. 31. var ds = new kendo.data.DataSource({32. transport: {33. read: function (options) {34. options.success(response);35. 36. }37. 38. },39. pageSize: pagesize,40. schema: { new_schema41. 42. }43. 44. }); 45. 46. ds.read();47. 48. console.log(ds);49. 50. if(typeof callback === "function") {51. callback(ds);52. 53. return true;54. 55. } else {56. return false;57. 58. }59. 60. }, function() { //error61. return false;62. 63. });64. 65.}1.12.:3.{column: "column1_name", type: "string"}4.25.:6.{column: "column2_name", type: "number"}