1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

feat(datatable): Valore di default paginazione

This commit is contained in:
Maicol Battistini
2021-11-30 15:12:48 +01:00
parent 17951a52dc
commit 51c1c5f5fe
2 changed files with 11 additions and 2 deletions

View File

@ -16,6 +16,14 @@ import TableRow from './TableRow.jsx';
export default class DataTable extends Component {
view(vnode) {
const rowsPerPageOptions: number[] = this.attrs.get('rows-per-page', '10,25,50,75,100').split(',')
.map((rowsPerPage: string) => Number.parseInt(rowsPerPage, 10));
let defaultRowsPerPage = Number.parseInt(this.attrs.get('default-rows-per-page', 10), 10);
if (!rowsPerPageOptions.includes(defaultRowsPerPage)) {
[defaultRowsPerPage] = rowsPerPageOptions;
}
return <div className="mdc-data-table" {...this.attrs.all()}>
<div className="mdc-data-table__table-container">
<table className="mdc-data-table__table" aria-label={this.attrs.get('aria-label')}>
@ -45,8 +53,9 @@ export default class DataTable extends Component {
className="mdc-data-table__pagination-rows-per-page-select"
fixedMenuPosition
style="--mdc-select-width: 112px; --mdc-select-height: 36px; --mdc-menu-item-height: 36px;"
value={defaultRowsPerPage}
>
{this.attrs.get('rows-per-page', '10,25,50,75,100').split(',').map(
{rowsPerPageOptions.map(
(value) => {
const rowsPerPage = Number.parseInt(value, 10);
return (