Why the code will run the onPageNavigationStart 3 times?

When I remove the lastpagedata from lastpage, it will update the pageCount and stimulate the obx, but I not sure why it will run 3 times onPageNavigationStart before display the data afte?


Future<void> removeStore(StoresModel store) async {
await DBService.removeStore(store.id!);

lastStoreID = storesList.last.id!;
storesList.removeWhere((item) => item.id == store.id);
if (store.id! == lastStoreID) {
DBService.lastStoreDoc = await DBService.getStoreDoc(storesList.last.id!);
}

_Store.storesLength = await DBService.getStoresLength();
_Store.pageCount.value =
(_Store.storesLength / _Store.rowsPerPage).ceilToDouble() as int;
lastPageData = _Store.storesLength % _Store.rowsPerPage;

print('newRemovePage: ${newPage}');
print('oldRemovePage: ${oldPage}');

stayOnPage = true;
if (newPage == (_Store.pageCount.value) && lastPageData == 0) {
print('(newPage == (_Store.pageCount.value) && lastPageData == 0) ');
storesList.insertAll(
0, await DBService.getStores(_Store.rowsPerPage, storesList));
print('AfterRemoveInsertPage: ${storesList.map((e) => e.name)}');
}
print('AfterRemoveHandlePage: ${storesList.map((e) => e.name)}');
Get.back();
}


child: Obx(
() => SfDataPager(
initialPageIndex: _stores.newPage + 1,
pageCount: pageCount.value as double,
visibleItemsCount: 1,
direction: Axis.horizontal,
delegate: _stores,
//Visualize the changes
onPageNavigationStart: (int pageIndex) {
print('onPageNavigationStart');
},
onPageNavigationEnd: (int pageIndex) {
print('onPageNavigationEnd');
},
),
)),


Attachment: RemoveStore_a9aa7f26.zip

1 Reply

TP Tamilarasan Paranthaman Syncfusion Team November 29, 2023 02:41 PM UTC

Hi Wong Pei San,

We have examined the reported issue on our end and observed that the callback was triggered twice, not three times. To assist us in addressing the issue you're encountering with the SfDataGrid, could you please modify the attached sample to reproduce the problem you're facing? Additionally, providing the precise steps to replicate the issue will greatly help us to investigate and resolve the specific problem you're experiencing with the SfDataGrid.


Regards,

Tamilarasan


Attachment: Sample_68644143.zip

Loader.
Up arrow icon