過去幾天我一直在努力尋找移動listview上的無盡滾動。按照演示建議,我已經設置了我的數據源和列表視圖。我無法在服務器端數據上成功運行(或按'加載更多')。本地數據按預期工作。我使用了許多不同的KendoUI核心版本,結果幾乎相同。使用KendoUI Mobile + Azure移動服務+ SQL Azure的EndlessScroll
但我注意到的一個區別是:演示中的「odata」部分拒絕爲我工作(500內部服務器錯誤)。因此,我在數據源上嘗試了一個正常的「GET」類型。 「GET」是odata風格(https://myserviceapi.azure-mobile.net/tables/EventTypes?$ filter = businessID%20eq%2053),它在Azure表格上開箱即用,但無盡的滾動不起作用。我也嘗試了一個Azure Mobile Services API方法的正常「GET」,它基本上是一個RESTful方法,該方法返回與SQL Azure中的odata表查詢相同的數據。沒有任何我嘗試過的工作。以下代碼是我擁有的許多Kendo UI Core構建和測試的代碼。
應用程序的JavaScript:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: 'https://myserviceapi.azure-mobile.net/tables/EventTypes?$filter=businessID%20eq%20' + busID,
dataType: "json"
}
},
serverPaging: true,
pageSize: 12
});
$("#photoHolder").kendoMobileListView({
dataSource: dataSource,
template: "<p>#: eventName #</p>",
endlessScrolling: true,
filterable:{
field: "eventName",
operator: "contains",
ignoreCase: true,
placeholder: "search products..."
}
});
HTML:
<ul id="photoHolder" data-role="listview">
</ul>
Azure中的JavaScript:
exports.get = function(request, response) {
var mssql = request.service.mssql;
var cnt = request.query.pageSize;
var pnm = request.query.page;
var sql = "SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY zOrder) AS RowNum, * FROM myschema.EventTypes where (businessID = " + request.query.busID + ") and active = 1) AS E " +
"WHERE RowNum BETWEEN ((" + pnm + " - 1) * cnt + 1) AND (" + pnm + " * " + cnt + ") ORDER BY zOrder";
mssql.query(sql, {
success: function(results) {
response.send(200, results);
},
error: function(err) {
console.log(err);
response.send(530, { error: err });
}
});
};
雖然這可能會在理論上回答這個問題,但[包括](// meta.stackoverflow.com/q/8259)這裏的答案的基本部分,並提供參考鏈接。 – SuperBiasedMan 2015-10-12 14:06:25
謝謝@SuperBiasedMan。我是StackOverflow的新手,發現了我的約定。我會盡我所能跟隨他們到最充分的。 – codeshinobi 2015-11-18 14:20:50