0
我正在使用以下javascript的光滑網格。問題是控件永遠不會確保Data()。有任何想法嗎?光滑的網格確保數據沒有被調用
grid.onViewportChanged.subscribe(function (e, args) {
alert('1');
var vp = grid.getViewport();
alert('2');
loader.ensureData(vp.top, vp.bottom);
alert('3');
});
function ensureData(from, to)
{
alert('55');
var maxdata = Math.min(999, data.length);
if (from < 0)
from = 0;
if (to > maxdata)
to = maxdata;
var fromPage = Math.floor(from/PAGESIZE);
var toPage = Math.floor(to/PAGESIZE); // look-ahead
while (fromPage <= toPage) {
if (data[fromPage * PAGESIZE] == undefined) {
data[fromPage * PAGESIZE] = null; // null indicates a 'requested but not available yet'
var order = { "query": searchstr, "offset": (fromPage * PAGESIZE), "count": (((toPage - fromPage) * PAGESIZE) + PAGESIZE), "sort": sortcol, "order": ((sortdir > 0) ? "asc" : "desc") };
req = $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(order),
url: "OrderService.svc/GetOrderList",
success: onSuccess,
error: function (jqXHR, textStatus, errorThrown) {
if (textStatus != 'abort')
onError(fromPage, toPage);
}
});
onDataLoading.notify();
}
fromPage++;
}
}
警報1所示然後被示 警報2然後 警報(錯誤裝載的數據)被示出&最後 警報3示出....