Hi Guys,
I have probably rather stupid, but still very frustrating problem with Kendo Datasource - particulary binding a remote service (json) to a list. I spent few hours yesterday reading, trying, experimenting - but to no avai, so this is my very last ressource...
It's the following scenario: I want to take an existing Kendo Mobile Ui example, "Pull to Refresh", which comes in the example folders when Kendo mobile is downloaded, but can also be found online here, and instead of binding it to Twitter REST service (as shown in the example), to bind it to my own datasource - data from remote REST service.
My service is located at:
http://sharedove.cld.sr/sahreconf2012/_vti_bin/ShareDoveRestService/ShareDove.svc/anonymous/GetSessions
So what I do with the original code is following:
- Change service address to the one above
- Change the name of the data field property from "results" (Twitter service) to "AllSessions" (my service)
- Change the template to show one single field ("TrackName")
What happens is following: In fiddler, I see my data loaded (hurray), with response code 200 (everything ok), but it just won't display (bind).
Screenshot of the Chrome developer tools with the service response selected is here.
So, I have no idea where does it go wrong. Everything looks plain and simple, I get my data, but it still would not show/bind.
Any ideas from you, good people?
Thanks!!
A, of course, my full code is (this is the "Pull to Refresh" example, with few lines modified):
I have probably rather stupid, but still very frustrating problem with Kendo Datasource - particulary binding a remote service (json) to a list. I spent few hours yesterday reading, trying, experimenting - but to no avai, so this is my very last ressource...
It's the following scenario: I want to take an existing Kendo Mobile Ui example, "Pull to Refresh", which comes in the example folders when Kendo mobile is downloaded, but can also be found online here, and instead of binding it to Twitter REST service (as shown in the example), to bind it to my own datasource - data from remote REST service.
My service is located at:
http://sharedove.cld.sr/sahreconf2012/_vti_bin/ShareDoveRestService/ShareDove.svc/anonymous/GetSessions
So what I do with the original code is following:
- Change service address to the one above
- Change the name of the data field property from "results" (Twitter service) to "AllSessions" (my service)
- Change the template to show one single field ("TrackName")
What happens is following: In fiddler, I see my data loaded (hurray), with response code 200 (everything ok), but it just won't display (bind).
Screenshot of the Chrome developer tools with the service response selected is here.
So, I have no idea where does it go wrong. Everything looks plain and simple, I get my data, but it still would not show/bind.
Any ideas from you, good people?
Thanks!!
A, of course, my full code is (this is the "Pull to Refresh" example, with few lines modified):
<!DOCTYPE html>
<
html
>
<
head
>
<
title
>Pull to refresh</
title
>
<
script
src
=
"../../../js/jquery.min.js"
></
script
>
<
script
src
=
"../../../js/kendo.mobile.min.js"
></
script
>
<
script
src
=
"../../content/shared/js/console.js"
></
script
>
<
link
href
=
"../../../styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"../../../styles/kendo.mobile.all.min.css"
rel
=
"stylesheet"
/>
</
head
>
<
body
>
<
a
href
=
"../index.html"
>Back</
a
>
<
div
data-role
=
"view"
data-init
=
"mobileListViewPullToRefresh"
data-title
=
"Pull to refresh"
>
<
header
data-role
=
"header"
>
<
div
data-role
=
"navbar"
>
<
span
data-role
=
"view-title"
></
span
>
<
a
data-align
=
"right"
data-role
=
"button"
class
=
"nav-button"
href
=
"#index"
>Index</
a
>
</
div
>
</
header
>
<
ul
id
=
"pull-to-refresh-listview"
></
ul
>
</
div
>
<
script
id
=
"pull-to-refresh-template"
type
=
"text/x-kendo-template"
>
<
div
class
=
"tweet"
>
#= TrackName #
</
div
>
</
script
>
<
script
>
function mobileListViewPullToRefresh() {
var lastID;
var dataSource = new kendo.data.DataSource({
serverPaging: true,
transport: {
read: {
url: "http://sharedove.cld.sr/sahreconf2012/_vti_bin/ShareDoveRestService/ShareDove.svc/anonymous/GetSessions", // the remove service url
dataType: "jsonp" // JSONP (JSON with padding) is required for cross-domain AJAX
},
parameterMap: function(options) {
var page = options.page;
var parameters = {
q: "javascript",
since_id: lastID //additional parameters sent to the remote service
}
return parameters;
}
},
change: function() {
var item = this.view()[0];
if (item) {
lastID = item.id_str;
}
},
schema: { // describe the result format
data: "AllSessions" // the data which the data source will be bound to is in the "results" field
}
});
$("#pull-to-refresh-listview").kendoMobileListView({
dataSource: dataSource,
pullToRefresh: true,
appendOnRefresh: true,
template: $("#pull-to-refresh-template").text()
});
}
</
script
>
<
style
scoped>
.tweet {
font-size: .8em;
line-height: 1.4em;
}
.pullImage {
width: 64px;
height: 64px;
border-radius: 3px;
float: left;
margin-right: 10px;
}
.sublink {
font-size: .9em;
font-weight: normal;
display: inline-block;
padding: 3px 3px 0 0;
text-decoration: none;
opacity: .8;
}
</
style
>
<
script
>
window.kendoMobileApplication = new kendo.mobile.Application(document.body);
</
script
>
</
body
>
</
html
>