Posted 15 February 2021, 5:28 am EST - Updated 3 October 2022, 2:29 pm EST
Hello Team grapecity,
Wijmo version: 5.20191.605
Angular version: 5.2
Following this sample
https://stackblitz.com/edit/angular-9-0-0-rc-1-9okodj?file=src%2Fapp%2Fapp.component.ts
Issue facing this:
1st 20 records load with this console error cannot read property "CurrentPosition "
while scrolling down, next 20 records not appending, only starting same 20 records remains there in Grid.
Debugging into it “CurrentPosition” shows 0
while scrolling, scrollChanged() function is call everytime .
Please have look in my code I added
IN HTML:
<wj-flex-grid #rbiCuiFlexGrid style="height: calc(100vh - 165px);overflow-y: scroll !important;"
[(itemsSource)]="[b]data1[/b]"
(scrollPositionChanged)="[b]scrollChanged[/b](rbiCuiFlexGrid)"
(formatItem)="addGearIcon(rbiCuiFlexGrid, $event)"
(initialized)="initializeGrid(rbiCuiFlexGrid)"
(loadedRows)="rbiCuiFlexGrid.autoSizeColumns()"
[isReadOnly]="true">
<wj-flex-grid-filter #filter class="row-filter"></wj-flex-grid-filter>
IN TS:
Variable declaration:
data1: wjcCore.CollectionView;
DataList: any[];
In given sample ForLoop is used to create grid records, but here in my case
we are getting data List from API .
this.[b]rbiCuiService[/b].getCUIRBIData(this.solvLiveDataModel)
.subscribe(DataGetFromAPI => {
this.DataList = DataGetFromAPI;
this.subscribeFunction(this.getData(20));
}
To iterate as per sample , assigned and get data from DataList through loop
getData(count) {
let data = [];
for (var i = 0; i < count; i++) {
data.push(
this.DataList[i]);
}
return new wjcCore.CollectionView(data);
}
Created same function as per sample
private subscribeFunction(view: wjcCore.CollectionView) {
// if data1 is not defined
if (!this.data1) {
// then create it
this.data1 = view;
} else {
// otherwise update items
let items = view.items;
Array.prototype.push.apply(this.data1.items, items); // push the new items
this.data1.refresh();
}
}
[b]scrollChanged[/b](s: wjcGrid.FlexGrid) {
// if we're close to the bottom, add 20 items
if (s.viewRange.bottomRow >= s.rows.length - 1) {
let view = s.collectionView;
let index = view.currentPosition; // keep position in case the view is sorted
// this.getData(10, view.items.length);
this.getData(20);
view.currentPosition = index;
}
}
Please let me know about this issue facing.
Thanks in Advance