Flutter, How can I change page programmaticly in PaginatedDataTable?
446
I create a key
final key = new GlobalKey<PaginatedDataTableState>();
Give key PaginatedDataTable
PaginatedDataTable(
key: key
...)
and ı use this function
key.currentState.pageTo(0);
you can look this question for use key state : Link
Author by
Şerefcan Oğuz
Updated on December 01, 2022Comments
-
Şerefcan Oğuz over 1 year
I have a PaginatedDataTable and searchbar, It's work great but when I Searched my DataTable is not going to first page. When I click first Page its going first page and my new filtered list is showing. How can I change page programmaticly in dataTable?
This my PaginatedDataTable
PaginatedDataTable paginatedDataTable = PaginatedDataTable( actions: [ AnimatedSearchBar( width: 300, textController: _searchController, onSuffixTap: () { setState(() { _searchController.text = ""; }); }), widget.showDialog == null ? SizedBox() : AddUpdateButton( buttonType: ButtonTypes.add, onPressed: widget.showDialog, ) ], initialFirstRowIndex: firstRowIndex, source: dts, rowsPerPage: _rowsPerPage, header: Text( widget.title, style: CustomTextStyle.mblackBoldTextStyle, ), sortColumnIndex: _sortColumnIndex, sortAscending: _sortAscending, availableRowsPerPage: [ _defaultRowsPerPage, _defaultRowsPerPage * 2, _defaultRowsPerPage * 5, _defaultRowsPerPage * 10 ], showCheckboxColumn: false, dataRowHeight: widget.dataRowHeight, showFirstLastButtons: true, onRowsPerPageChanged: (r) { setState(() { _rowsPerPage = r; }); }, columns: widget.headerList.map((e) { return DataColumn( label: Text(e.name.toUpperCase()), onSort: (int columnIndex, bool ascending) { if (e.sort) { return _sort( (T d) => d.getProp(e.propName), columnIndex, ascending); } }); }).toList(), );
-
pskink over 2 yearstry
PaginatedDataTableState.pageTo()
method -
Şerefcan Oğuz over 2 yearsthank you I solved same way @pskink
-