Description
ListGrid displays a list of objects in a grid, where each row represents one object and each cell in the row represents one property.
...
For transparent loading of the data theĀ fetchData method should be used.
Code Block |
---|
langlanguage | javascriptjs |
---|
title | Update by DataSource |
---|
lang | javascript |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
var onRefresh = function() {
var dataSource = supplyItemListGrid.getDataSource();
var request = { visibleRows = supplyItemListGrid.getVisibleRows();
// request one page's worth of data on either side of the current viewport
var startRow: = visibleRows[0] - supplyItemListGrid.data.resultSize,
endRow: (supplyItemListGrid.getVisibleRows() = visibleRows[1] + supplyItemListGrid.data.resultSize;
if (startRow < 0) {
startRow = 0;
}
var request = {
startRow: startRow,
endRow: endRow,
sortBy: supplyItemListGrid.getSort(),
showPrompt: false
};
var selectedRows = supplyItemListGrid.getSelectedState() var callback = function(dsResponse,data,dsRequest) {
var result = dsResponse.data,
initialData = [];
// correctly position the result in the resultset's cache
initialData.length = dsResponse.totalRows;
copyArray(result, initialData, dsResponse.startRow);
var resultSet = isc.ResultSet.create({
dataSource: supplyItemListGrid.getDataSource(),
initialLength: dsResponse.totalRows,
initialData: dsResponse.data,initialData,
sortSpecifiers: supplyItemListGrid.getSort(),
criteria: supplyItemListGrid.getCriteria()
});
supplyItemListGrid.setData(resultSet);
supplyItemListGrid.setSelectedState(selectedRows);};
dataSource.fetchData(supplyItemListGrid.getCriteria(), callback, request);
}
// copy all elements from the src array to the dest array, beginning at startPos
function copyArray(src, dest, startPos) {
start = start || 0;
for (var i=0; i < src.length; i++) {
dest.set(start + i, src.get(i));
}
}
|
Attachments