JavaScript
var url = 'https://services.odata.org/V4/Northwind/Northwind.svc';
// ODataVirtualCollectionView: 뷰포트 범위 데이터만 서버 요청
var virtualView = new wijmo.odata.ODataVirtualCollectionView(
url,
'Order_Details_Extendeds',
{
oDataVersion: 4,
loaded: function(sender) {
// 총 레코드 수 표시 (전체 데이터 로드 없이 Count 쿼리로 취득)
document.getElementById('countLabel').textContent =
'총 ' + sender.totalItemCount.toLocaleString() + '건 (현재 뷰포트만 로드됨)';
}
}
);
var grid = new wijmo.grid.FlexGrid('#virtualGrid', {
autoGenerateColumns: false,
isReadOnly: true,
columns: [
{ binding: 'OrderID', header: '주문 번호', width: 100 },
{ binding: 'ProductID', header: '제품 번호', width: 100 },
{ binding: 'UnitPrice', header: '단가', width: 100, format: 'n2' },
{ binding: 'Quantity', header: '수량', width: 80, format: 'n0' },
{ binding: 'Discount', header: '할인율', width: 80, format: 'p0' },
{ binding: 'ExtendedPrice', header: '합계', width: 120, format: 'n2' }
],
itemsSource: virtualView
});
// 2024v2-HF 미만 버전 사용 시 수동으로 setWindow 호출
// 최신 버전에서는 ODataVirtualCollectionView가 자동으로 처리함
grid.scrollPositionChanged.addHandler(function(s) {
var rng = s.viewRange;
virtualView.setWindow(rng.topRow, rng.bottomRow);
});