Skip to content

Commit 72807e5

Browse files
committed
Add type hints for pageLength
1 parent 3b06b96 commit 72807e5

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ITables ChangeLog
99

1010
**Fixed**
1111
- We have added a `Typing :: Typed` classifier to the package as ITables now comes with type annotations ([#411](https://github.com/mwouts/itables/issues/411))
12+
- Added type hints and an example for `pageLength` ([#410](https://github.com/mwouts/itables/issues/410))
1213

1314

1415
2.4.1 (2025-06-10)

docs/options/length_menu.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kernelspec:
1414

1515
# LengthMenu
1616

17-
Select [how many entries](https://datatables.net/examples/advanced_init/length_menu.html) should appear at once in the table with either the `lengthMenu` argument of the `show` function, or with the global option `itables.options.lengthMenu`:
17+
Select [how many entries](https://datatables.net/examples/advanced_init/length_menu.html) should appear at once in the table with either the `lengthMenu` argument of the `show` function, or with the global option `itables.options.lengthMenu`. Use `pageLength` to set the default page length:
1818

1919
```{code-cell} ipython3
2020
import itables
@@ -26,5 +26,5 @@ df = itables.sample_dfs.get_countries(html=False)
2626
```{code-cell} ipython3
2727
:tags: [full-width]
2828
29-
itables.show(df, lengthMenu=[2, 5, 10, 20, 50])
29+
itables.show(df, lengthMenu=[2, 5, 10, 20, 50], pageLength=5)
3030
```

docs/py/options/length_menu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# %% [markdown]
1818
# # LengthMenu
1919
#
20-
# Select [how many entries](https://datatables.net/examples/advanced_init/length_menu.html) should appear at once in the table with either the `lengthMenu` argument of the `show` function, or with the global option `itables.options.lengthMenu`:
20+
# Select [how many entries](https://datatables.net/examples/advanced_init/length_menu.html) should appear at once in the table with either the `lengthMenu` argument of the `show` function, or with the global option `itables.options.lengthMenu`. Use `pageLength` to set the default page length:
2121

2222
# %%
2323
import itables
@@ -26,4 +26,4 @@
2626
df = itables.sample_dfs.get_countries(html=False)
2727

2828
# %% tags=["full-width"]
29-
itables.show(df, lengthMenu=[2, 5, 10, 20, 50])
29+
itables.show(df, lengthMenu=[2, 5, 10, 20, 50], pageLength=5)

src/itables/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
Sequence[Sequence[Union[int, str]]],
108108
]
109109
]
110+
pageLength: Optional[int]
110111
columnDefs: Optional[Sequence[Mapping[str, Any]]]
111112
paging: Optional[bool]
112113
autoWidth: Optional[bool]

src/itables/typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class DataTableOptions(TypedDict):
5454
Sequence[Sequence[Union[int, str]]],
5555
]
5656
]
57+
pageLength: NotRequired[int]
5758
order: NotRequired[
5859
Union[Sequence[Sequence[Union[int, str]]], Mapping[str, Union[int, str]]]
5960
]

0 commit comments

Comments
 (0)