首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤栗,如何在PaginatedDataTable中编程更改页面?

颤栗,如何在PaginatedDataTable中编程更改页面?
EN

Stack Overflow用户
提问于 2021-09-13 12:33:48
回答 1查看 913关注 0票数 2

我有一个PaginatedDataTable和搜索栏,它的工作很好,但当我搜索我的DataTable并不是第一页。当我点击第一页,它将第一页和我的新过滤列表显示。如何在dataTable中编程更改页面?

这是我的PaginatedDataTable

代码语言:javascript
复制
    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(),
  );
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-13 14:21:59

我创建了一个密钥

代码语言:javascript
复制
final key = new GlobalKey<PaginatedDataTableState>();

给密钥PaginatedDataTable

代码语言:javascript
复制
 PaginatedDataTable(
        key: key
        ...)

ı使用此函数

代码语言:javascript
复制
key.currentState.pageTo(0);

您可以查看以下问题以获得使用密钥状态:Link

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69162767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档