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:
@ -16,6 +16,14 @@ import TableRow from './TableRow.jsx';
|
|||||||
|
|
||||||
export default class DataTable extends Component {
|
export default class DataTable extends Component {
|
||||||
view(vnode) {
|
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()}>
|
return <div className="mdc-data-table" {...this.attrs.all()}>
|
||||||
<div className="mdc-data-table__table-container">
|
<div className="mdc-data-table__table-container">
|
||||||
<table className="mdc-data-table__table" aria-label={this.attrs.get('aria-label')}>
|
<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"
|
className="mdc-data-table__pagination-rows-per-page-select"
|
||||||
fixedMenuPosition
|
fixedMenuPosition
|
||||||
style="--mdc-select-width: 112px; --mdc-select-height: 36px; --mdc-menu-item-height: 36px;"
|
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) => {
|
(value) => {
|
||||||
const rowsPerPage = Number.parseInt(value, 10);
|
const rowsPerPage = Number.parseInt(value, 10);
|
||||||
return (
|
return (
|
||||||
|
@ -263,7 +263,7 @@ export default class RecordsPage extends Page {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2>{this.title}</h2>
|
<h2>{this.title}</h2>
|
||||||
<DataTable checkable paginated rows-per-page="1">
|
<DataTable checkable paginated>
|
||||||
{this.tableColumns()}
|
{this.tableColumns()}
|
||||||
{this.tableRows()}
|
{this.tableRows()}
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
Reference in New Issue
Block a user