I'm sorry, but after searching the DataSource API and this forum I am not finding out how to do the following:
I have a Node.JS server connected to a PostGIS database. It stores a number of rows that have a field called: outline that is a long GeoJSON object. In my model, I declare the simple fields (number, data, etc.) just fine. But is this correct for the JSON data. I will connect this to a KendoGrid, but I do not want the user to see it.
What I want him to do is sort, select, etc. based on the other fields, and then I will use the hidden GeoJSON outline (I will fetch it with the dataSource.data() method to get the values from it for map display.
But first, is this the "json" a correct type for the outline?
I have a Node.JS server connected to a PostGIS database. It stores a number of rows that have a field called: outline that is a long GeoJSON object. In my model, I declare the simple fields (number, data, etc.) just fine. But is this correct for the JSON data. I will connect this to a KendoGrid, but I do not want the user to see it.
What I want him to do is sort, select, etc. based on the other fields, and then I will use the hidden GeoJSON outline (I will fetch it with the dataSource.data() method to get the values from it for map display.
But first, is this the "json" a correct type for the outline?
function buildDataModel() { DataModel.data = new kendo.data.DataSource({ type:"json", pageSize: 5000, //change to infinite when bug fixed. transport:{ read:{ url:AppGlobals.serverURL + "Search", dataType:"json" } }, schema:{ data:"results", total:"count", model:{ fields:{ pid:{ type:"number" }, size:{ type:"number" }, date:{ type:"date" }, type:{ type:"string" }, egpl_date:{ type:"date" }, cocom:{ type:"string" }, country:{ type:"string" }, product_name:{ type:"string" }, outline:{ type:"json" } } } }, error:function (e) { alert("DataMode.js datasource error: " + "\nthrew: " + e.errorThrown + "\nstatus: " + e.status + "\nerrors:" + e.errors + "\nurl: " + e.sender.transport.options.read.url); }, change:function (e) { newData(e); } });}7 Answers, 1 is accepted
0
Dr.YSG
Top achievements
Rank 2
answered on 05 Mar 2014, 08:25 PM
So here is an example record that I am sending from the Node.JS server to the browser (to be parsed with the kendo.DataSource).
As you can see, everything but outline, is a simple string, data, or numeric. But I want the outline to be preserved in the DataSource as a JSON object. The issue is that if I say the field type is "json" or "object" I get the following back when I call grid.dataTime(<rowID>) (see second json. Note all the dt.extend.init objects).
This is what I get see if when retrieving the grid.dataItem(0).outline:
As you can see, everything but outline, is a simple string, data, or numeric. But I want the outline to be preserved in the DataSource as a JSON object. The issue is that if I say the field type is "json" or "object" I get the following back when I call grid.dataTime(<rowID>) (see second json. Note all the dt.extend.init objects).
001.{002. "pid": 23501,003. "product_name": "DTED120",004. "type": "DTED1",005. "country": "Poland",006. "size": 522782213,007. "cocom": "EUCOM",008. "egpl_date": "2013-03-28T06:47:56.334Z",009. "outline": {010. "type": "Polygon",011. "crs": {012. "type": "name",013. "properties": {014. "name": "EPSG:4326"015. }016. },017. "coordinates": [018. [019. [020. 19.0004167,021. 48.9995833022. ],023. [024. 18.9995833,025. 48.9995833026. ],027. [028. 18.0004167,029. 48.9995833030. ],031. [032. 17.9995833,033. 48.9995833034. ],035. [036. 16.9995833,037. 48.9995833038. ],039. [040. 16.9995833,041. 49.9995833042. ],043. [044. 16.9991667,045. 49.9995833046. ],047. [048. 16.0008333,049. 49.9995833050. ],051. [052. 15.9991667,053. 49.9995833054. ],055. [056. 15.0008333,057. 49.9995833058. ],059. [060. 14.9991667,061. 49.9995833062. ],063. [064. 13.9991667,065. 49.9995833066. ],067. [068. 13.9991667,069. 50.9995833070. ],071. [072. 13.9991667,073. 51.0004167074. ],075. [076. 13.9991667,077. 51.9995833078. ],079. [080. 13.9991667,081. 52.0004167082. ],083. [084. 13.9991667,085. 52.9995833086. ],087. [088. 13.9991667,089. 53.0004167090. ],091. [092. 13.9991667,093. 54.0004167094. ],095. [096. 14.9991667,097. 54.0004167098. ],099. [100. 15.0008333,101. 54.0004167102. ],103. [104. 15.9991667,105. 54.0004167106. ],107. [108. 16.0008333,109. 54.0004167110. ],111. [112. 16.9991667,113. 54.0004167114. ],115. [116. 17.0008333,117. 54.0004167118. ],119. [120. 17.9991667,121. 54.0004167122. ],123. [124. 18.0008333,125. 54.0004167126. ],127. [128. 18.9991667,129. 54.0004167130. ],131. [132. 19.0008333,133. 54.0004167134. ],135. [136. 19.9991667,137. 54.0004167138. ],139. [140. 20.0008333,141. 54.0004167142. ],143. [144. 20.9991667,145. 54.0004167146. ],147. [148. 21.0008333,149. 54.0004167150. ],151. [152. 21.9991667,153. 54.0004167154. ],155. [156. 22.0008333,157. 54.0004167158. ],159. [160. 22.9991667,161. 54.0004167162. ],163. [164. 23.0008333,165. 54.0004167166. ],167. [168. 24.0008333,169. 54.0004167170. ],171. [172. 24.0008333,173. 53.0004167174. ],175. [176. 24.0008333,177. 52.9995833178. ],179. [180. 24.0008333,181. 51.9995833182. ],183. [184. 23.0008333,185. 51.9995833186. ],187. [188. 23.0008333,189. 51.0004167190. ],191. [192. 23.0008333,193. 50.9995833194. ],195. [196. 23.0008333,197. 49.9995833198. ],199. [200. 22.0008333,201. 49.9995833202. ],203. [204. 22.0004167,205. 49.9995833206. ],207. [208. 22.0004167,209. 48.9995833210. ],211. [212. 21.0004167,213. 48.9995833214. ],215. [216. 20.9995833,217. 48.9995833218. ],219. [220. 20.0004167,221. 48.9995833222. ],223. [224. 19.9995833,225. 48.9995833226. ],227. [228. 19.0004167,229. 48.9995833230. ]231. ]232. ]233. }234.},This is what I get see if when retrieving the grid.dataItem(0).outline:
Watch Expressionsbounds: dt.extend.init_events: Objectcoordinates: dt.extend.init[1]0: Array[53]_events: Objectlength: 1parent: function (){return i}type: function (e){var t,n,i=this,r=function(){return i};dt.fn.init.call(this);for(n in e)t=e[n],"_"!=n.charAt(0)&&(t=i.wrap(t,n,r)),i[n]=t;i.uid=st.guid()}__proto__: n.extend.icrs: dt.extend.init_events: Objectparent: function (){return i}properties: dt.extend.inittype: "name"uid: "f9fd34d1-6362-47b7-91f5-8b67f7919f41"__proto__: n.extend.iparent: function (){return i}type: "Polygon"uid: "9348b924-3ea1-4531-b724-64cc7eba6a16"__proto__: n.extend.i0
Hello Yechezkal,
Basically you do not have to do anything in your case. The nested JSON field will still be available on the client when getting the dataItem from the dataSource.
Just omit specifying it and let me know y our findings.
Kind Regards,
Petur Subev
Telerik
Basically you do not have to do anything in your case. The nested JSON field will still be available on the client when getting the dataItem from the dataSource.
Just omit specifying it and let me know y our findings.
Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dr.YSG
Top achievements
Rank 2
answered on 07 Mar 2014, 02:44 PM
So if I understand your correctly,
var geoJSON = dataSource[x];
will return a JSON object, with none of the dt decoration?
And that I should declare the field in the DataSource as type: "object",
is that correct?
var geoJSON = dataSource[x];
will return a JSON object, with none of the dt decoration?
And that I should declare the field in the DataSource as type: "object",
is that correct?
0
Dr.YSG
Top achievements
Rank 2
answered on 07 Mar 2014, 02:45 PM
I mean to say with none of the dt.extend.init decoration,
and to get the object via
grid.dataItem(X);
Is that correct?
and to get the object via
grid.dataItem(X);
Is that correct?
0
Hello again Yechezkal,
There is no such type definition. Just omit specifying this in the dataSource.schema configuration.
It will still be available. Take a look at the code that you shared:
You can access the nested array like this
Kind Regards,
Petur Subev
Telerik
There is no such type definition. Just omit specifying this in the dataSource.schema configuration.
It will still be available. Take a look at the code that you shared:
coordinates: dt.extend.init[1]0: Array[53]You can access the nested array like this
var coordinates = grid.dataItem(X).coordinates[0];// you can then iterate over the coordinates arrayKind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dr.YSG
Top achievements
Rank 2
answered on 12 Mar 2014, 03:05 PM
Hello Petur,
I follow that. But is this worth adding as a user voice request? Afterall, I do not want to manually go through the coordinate list to create a GeoJSON object. What I want to do is store JSON directly in the DataSource, and then grab that JSON and create use the Leaflet create layer, which takes GeoJSON as a parameter.
Seems like an easy thing to add to the current field types (number, string, data, etc.) to add a JSON type, and then not do any interpretation on it.
I follow that. But is this worth adding as a user voice request? Afterall, I do not want to manually go through the coordinate list to create a GeoJSON object. What I want to do is store JSON directly in the DataSource, and then grab that JSON and create use the Leaflet create layer, which takes GeoJSON as a parameter.
Seems like an easy thing to add to the current field types (number, string, data, etc.) to add a JSON type, and then not do any interpretation on it.
0
Hello Yechezkal,
Feel free to share this as an idea on our feedback portal. If many users find it useful, the Dev team will consider it.
http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback
Kind Regards,
Petur Subev
Telerik
Feel free to share this as an idea on our feedback portal. If many users find it useful, the Dev team will consider it.
http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback
Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!