Skip to content

Commit

Permalink
Update documentation examples to use 'all'
Browse files Browse the repository at this point in the history
+ fix docs-only `data_store.findUsers` to handle 'all' string

+ add datagrid pagination 'all' example, mostly for testing

+ add in_memory table `all` pagination, mostly for testing
  • Loading branch information
cee-chen committed Feb 11, 2022
1 parent 6903978 commit 2a05385
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src-docs/src/views/datagrid/in_memory_pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100],
pageSizeOptions: [10, 50, 100, 'all'],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
12 changes: 6 additions & 6 deletions src-docs/src/views/pagination/paginated_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export default () => {
const totalItemCount = raw_data.length;
const startIndex = pageIndex * pageSize;
const pageOfItems =
pageSize > 0
? raw_data.slice(
pageSize === 'all'
? raw_data
: raw_data.slice(
startIndex,
Math.min(startIndex + pageSize, totalItemCount)
)
: raw_data;
);

const columns = [
{
Expand Down Expand Up @@ -93,11 +93,11 @@ export default () => {
pageIndex,
pageSize,
totalItemCount,
pageSizeOptions: [10, 0],
pageSizeOptions: [10, 'all'],
};

const resultsCount =
pageSize === 0 ? (
pageSize === 'all' ? (
<strong>All</strong>
) : (
<>
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/tables/data_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const createDataStore = () => {

let pageOfItems;

if (!pageIndex && !pageSize) {
if ((!pageIndex && !pageSize) || pageSize === 'all') {
pageOfItems = items;
} else {
const startIndex = pageIndex * pageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ export const Table = () => {
}
items={users}
columns={columns}
pagination={pagination}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100, 'all'],
}}
sorting={sorting}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/tables/paginated/paginated.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export const Table = () => {
pageIndex,
pageSize,
totalItemCount,
pageSizeOptions: [10, 0],
pageSizeOptions: [10, 'all'],
showPerPageOptions,
};

const resultsCount =
pageSize === 0 ? (
pageSize === 'all' ? (
<strong>All</strong>
) : (
<>
Expand Down

0 comments on commit 2a05385

Please sign in to comment.