This (http://dojo.telerik.com/OpupU) is a Dojo example that prints the length of a remote DataSource's data. When I substitute in a different URL (one running on my local machine) but don't change anything else, nothing gets logged to the console. In particular, the change function is never called.
Here is information about the data I'm trying to pull in:
The JSON data:
[{
"tradeVolume"
:
"33454327"
,
"numberOfTrades"
:
"130498"
,
"tradeSizeStdDev"
: 13048.15096724034,
"quoteSizeStdDev"
: 1306.394869511115,
"medianTrade"
: 100.0,
"eightiethTradeSize"
: 200.0,
"ninetiethTradeSize"
: 334.2000000000029,
"ninetyFifthTradeSize"
: 334.2000000000029,
"ninetyEighthTradeSize"
: 1100.0,
"ninetyNinthTradeSize"
: 2000.0,
"medianQuoteSize"
: 1000.0,
"eightiethQuoteSize"
: 1550.0,
"ninetiethQuoteSize"
: 2050.0,
"ninetyFifthQuoteSize"
: 2050.0,
"ninetyEighthQuoteSize"
: 4300.0,
"ninetyNinthQuoteSize"
: 5600.0,
"ninetyNinthFiveQuoteSize"
: 7850.0
}]
Screenshots of the Chrome DevTools Network Headers and Response are linked here: https://i.imgsafe.org/6d2625717d.png and https://i.imgsafe.org/6d29a5a600.png
Can
someone explain why the Dojo example isn't working when I substitute in
my url containing the above data and tell me how I could fix it? I
wonder if it has to do with the "keep-alive" connection.
Thanks!
9 Answers, 1 is accepted
Trying to open the provided screenshots resulted in an error (see the attachment). Can you please attach them to your response, and send them again.
In general, the Kendo UI DataSource works as expected, regardless of whether the remote data service is running on a remote server, or on the local machine. You can inspect the browser's developers tools (F12) console for JavaScript errors, and the Network tab to investigate what is happening with the request.
If the problem persists, please send us further details about the scenario and resulting issue, so we can provide further and more to-the-point suggestions.
Regards,
Dimiter Topalov
Telerik by Progress
Hi Dimiter,
I checked my browser's developers tools and the network tab, although the request was successful (i.e., I could see the json in Network/Response), it wasn't logging the length of the data to the console.
I tried creating a test.html file and hosting it on the same server as my remote data source. I changed the dataType from "jsonp" to "json", and added a schema model, since the data is an array of an object of objects (slightly different from the one I posted previously, see below).
[{
"date"
: {
"text"
:
"2015-07-13"
},
"barData"
: {
"tradeVolume"
:
"33454327"
,
"numberOfTrades"
:
"130498"
,
"tradeSizeStdDev"
: 13048.15096724034,
"quoteSizeStdDev"
: 1306.394869511115,
"medianTrade"
: 100.0,
"eightiethTradeSize"
: 200.0,
"ninetiethTradeSize"
: 334.2000000000029,
"ninetyFifthTradeSize"
: 334.2000000000029,
"ninetyEighthTradeSize"
: 1100.0,
"ninetyNinthTradeSize"
: 2000.0,
"medianQuoteSize"
: 1000.0,
"eightiethQuoteSize"
: 1550.0,
"ninetiethQuoteSize"
: 2050.0,
"ninetyFifthQuoteSize"
: 2050.0,
"ninetyEighthQuoteSize"
: 4300.0,
"ninetyNinthQuoteSize"
: 5600.0,
"ninetyNinthFiveQuoteSize"
: 7850.0
}
}]
Here's another Dojo with the content of my test.html file: http://dojo.telerik.com/@juliayu/apEHA. Although you won't be able to access the url, here are the things I tried (the code for each of these is in the Dojo link, and some are commented out):
- Logging the length of the data and the data itself whenever the remote DataSource is changed. This didn't print the right information (i.e., it wasn't an observable object containing the json data) .
- Calling the fetch method on the remote DataSource and logging the data. This also didn't print the right information.
- Printing the remote DataSource data twice after calling the read method. This didn't work either.
I'm sorry you weren't able to open my screenshots. I'll try attaching the files again when I get off work.
Thanks!
Julia
Sorry, the above were the original screenshots. The ones attached here are the ones corresponding to the newest post.
The Kendo UI DataSource change event is fired whenever tha dataSource is populated, an item is changed, added, or removed, and when a the data is paged, sorted, filtered, or grouped:
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-change
The dataSource schema, and schema.model are described in the following sections of the API reference:
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.model
... and a thorough Overview is available in the following section:
http://docs.telerik.com/kendo-ui/framework/datasource/overview
I have prepared a simple dojo illustrating some of the dataSource's methods and the change event. You can find out more in our online demos, and all - in the API reference:
http://demos.telerik.com/kendo-ui/datasource/index
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource
Let us know if you have other questions about Kendo UI.
Regards,
Dimiter Topalov
Telerik by Progress
Thanks for the links Dimiter! I was able to get it to work.
For reference, my schema definition was wrong. Here's a Dojo with the working code: http://dojo.telerik.com/@juliayu/apEHA/4