我有一个PaginatedDataTable和搜索栏,它的工作很好,但当我搜索我的DataTable并不是第一页。当我点击第一页,它将第一页和我的新过滤列表显示。如何在dataTable中编程更改页面?
这是我的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(),
);发布于 2021-09-13 14:21:59
我创建了一个密钥
final key = new GlobalKey<PaginatedDataTableState>();给密钥PaginatedDataTable
PaginatedDataTable(
key: key
...)ı使用此函数
key.currentState.pageTo(0);您可以查看以下问题以获得使用密钥状态:Link
https://stackoverflow.com/questions/69162767
复制相似问题