or
<script id=
"endless-scrolling-template"
type=
"text/x-kendo-template"
>
<div class=
"resultline"
>
#= company_name #
<span class=
"sublink"
>
#=company_num #/#= company_bus_ind # </span>
</div>
</script>
<script>
function
mobileListViewEndlessScrolling() {
var
dataSource =
new
kendo.data.DataSource({
pageSize: 10,
serverPaging:
true
,
transport: {
read: {
url:
"OpenServiceWrapper/customlist"
,
// the remove service url
dataType:
"json"
},
parameterMap:
function
(options) {
var
parameters = {
//additional parameters sent to the remote service
company_name:
"bank"
,
company_bus_ind:
"c"
,
max: options.pageSize,
page: options.page,
//next page -- this is automatically incremented as part of kendo
totalCount: $(
"#company-matches-found"
).html()
}
return
parameters;
}
},
change:
function
(e) {
// console.log("Page = " + e.sender._page);
// console.log("Page size = " + e.sender._pageSize);
// console.log("Next page = " + dataSource._pristine.next_page);
// console.log("Previous page = " + dataSource._pristine.previous_page);
// console.log("Total count = " + dataSource._pristine.total_count);
var
t = dataSource._pristine.total_count;
console.log($(
"#company-matches-found"
).html(t));
var
m = e.sender._page * e.sender._pageSize;
if
(m >= t) {
alert(
"That's it... no more matches"
);
// I want to flick off server side call back here
}
},
schema: {
// describe the result format: this should correspond to class CustomCompany
total:
"total_count"
,
page:
"page"
,
data:
"results"
,
// the data which the data source will be bound to is in the "results" field
model: {
fields: {
company_num: {
type:
'number'
},
company_name: {
type:
'string'
},
company_bus_ind: {
type:
'string'
}
}
}
}
});
$(
"#endless-scrolling"
).kendoMobileListView({
dataSource: dataSource,
template: $(
"#endless-scrolling-template"
).text(),
endlessScroll:
true
,
scrollTreshold: 30
//treshold in pixels
});
}
</script>
<
div
id
=
"view-list"
data-role
=
"view"
data-layout
=
"view-layout"
>
<
div
>
<
ul
id
=
"list"
>
</
ul
>
</
div
>
</
div
>
var
dataSource =
new
kendo.data.DataSource({
pageSize: 10,
page: 1,
serverPaging:
true
,
transport: {
read: {
url: url,
dataType:
"jsonp"
},
parameterMap:
function
(options) {
var
parameters = {
pageSize: options.pageSize,
page: options.page
}
return
parameters;
}
},
schema: {
data:
function
(data) {
return
data.result;
},
total:
function
(data) {
return
data.count; // total number of items
}
},
error:
function
() {
onError(
"Communication error"
);
}
});
if
($(
"#list"
).data(
"kendoMobileListView"
) == undefined) {
$(
"#list"
).kendoMobileListView({
dataSource: dataSource,
template: $(
"#template"
).html(),
endlessScroll:
true
,
scrollTreshold: 30,
click:
function
(e) {
...
}
});
}
else
{
$(
"#list"
).data(
"kendoMobileListView"
).dataSource = dataSource;
$(
"#list"
).data(
"kendoMobileListView"
).refresh();
}