현재 시나리오를 스크롤 막대 스크롤에 레코드를로드해야합니다. 빈 드롭 다운 목록이 있고 처음로드 할 때 서버에서 검색된 처음 20 개의 레코드를 추가합니다. 드롭 다운 스크롤에서 서버에서 20 레코드를 받고 드롭 다운에 추가 중입니다. 스크롤바 이벤트에서이 프로세스를 반복하고 다음 20 개 레코드와 다음 20 개 레코드를 드롭 다운에 추가합니다.Jquery가 모든 레코드를로드 할 때
다음은 내 코드/알고리즘입니다.
내 질문 : 서버에서 20 개를로드하는 대신 모든 레코드를 한 번에로드 할 수있는 옵션이 있습니까?
단점 : 한 번에 20 레코드 만 반환합니다. 페이지 크기는 20으로 설정됩니다. odata 업데이트를 제어 할 권한이 없습니다. 시나리오를 20 번씩 20 번씩 반복해야하고 페이지로드시 전체를 합쳐야합니다.
var nextCitiesLink = null;
var pgLoading = false;
$("#SelectedNames").bind('scroll', function(e) {
loadCityNames();
});
function loadCityNames() {
if (!pgLoading && nextLinkPgs != null) {
pgLoading = true;
$.ajax({
type: "GET",
url: nextCitiesLink,
crossDomain: true,
cache: false,
contentType: 'application/json; charset=utf-8',
xhrFields: {
withCredentials: true
},
success: function (result) {
debugger;
var namesDrpdown = $('#SelectedNames');
$.each(result.value, function(val, data) {
namesDrpdown.append($('<option></option>').val(data.Id).html(data.Name));
});
nextCitiesLink= "odatalink&$skip=20";
pgLoading = false;
},
complete: function() {
}
});
}
}