Dev-Owl / advanced_datatable

Advanced Datatable uses the Fultter PaginatedDataTable Widget and adds a few more functions to it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data not changed in getNextPage() function

a7mdragab opened this issue · comments

Hello,
Thanks for your effort.

I have a problem with this widget!
I have implemented it and it worked fine, then I noticed that when I paginate to any page, it displays only the first rows in every page.

This is my function:

@override
  Future<RemoteDataSourceDetails> getNextPage(
      NextPageRequest pageRequest) async {

    return await func(pageRequest.offset, pageRequest.pageSize).then((_) {
      print('First object = ${data[pageRequest.offset].toJson()}');
      print(
          'Last object = ${data[min(pageRequest.offset + pageRequest.pageSize - 1, rowCount - 1)].toJson()}');
      return RemoteDataSourceDetails(
        rowCount,
        data.skip(pageRequest.offset).take(pageRequest.pageSize).toList(),
      );
    });
  }

The function func(pageRequest.offset, pageRequest.pageSize) is used to fetch the data from the server and assign it to the datasource data.

Example:
I have a list with 250 elements in mysql table.
RowsPerPage is 100
The first time the widget is loaded with the first 100 rows successfully with first row 0 and last row = 99
When I paginate to the next page it displays from 0 to 100 again however first row 100 and last row = 199

What could be the problem?

Ops, I was using data list instead of lastDetails. it worked fine now.