Any Example for custom pagination in material-table and reactjs

落花浮王杯 提交于 2021-02-18 22:52:58

问题


Any Example for custom pagination? material-table and reactjs. I want to pass from and to page size to the server and need to hide the first and last button from paging


回答1:


Styudy this example https://material-table.com/#/docs/features/component-overriding in order to understand better the code i will show: With this you can access directly to the pagination component and make the call by your own.

       `components={{
              Pagination: props => (
                           <TablePagination
                           {...props}
                          rowsPerPageOptions={[5, 10, 20, 30]}
                      rowsPerPage={this.state.numberRowPerPage}
                      count={this.state.totalRow}
                      page={
                        firstLoad
                          ? this.state.pageNumber
                          : this.state.pageNumber - 1
                      }
                      onChangePage={(e, page) =>
                        this.handleChangePage(page + 1)
                      }
                      onChangeRowsPerPage={event => {
                        props.onChangeRowsPerPage(event);
                        this.handleChangeRowPerPage(event.target.value);
                      }}
                    />
                  ),
                        }}`

Using the same way you can change the text of this buttons, please check this example https://material-table.com/#/docs/features/localization.

Best Regards



来源:https://stackoverflow.com/questions/56214292/any-example-for-custom-pagination-in-material-table-and-reactjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!