Skip to content

Commit e960b46

Browse files
authored
Display just the table (no search box, no summary) when the table only has a few rows (#147)
* display only the table (no controls) if it fits in one page * Version 1.4.3
1 parent 41f1422 commit e960b46

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019-2022 Marc Wouts
3+
Copyright (c) 2019-2023 Marc Wouts
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/advanced_parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ opt.lengthMenu = [5, 10, 20, 50, 100, 200, 500]
122122

123123
## Removing the search box
124124

125-
By default, datatables comes with a search box, a pagination control, a table summary, etc.
125+
By default, datatables that don't fit in one page come with a search box, a pagination control, a table summary, etc.
126126
You can select which elements are actually displayed using
127127
DataTables' [`dom` option](https://datatables.net/reference/option/dom) with e.g.:
128128

docs/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
ITables ChangeLog
22
=================
33

4+
1.4.3 (2023-01-14)
5+
------------------
6+
7+
**Changed**
8+
- When a table is made of only a few rows, we display just the table (not the search box, pagination control, etc)
9+
10+
411
1.4.2 (2022-12-23)
512
------------------
613

itables/javascript.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def to_html_datatable(df=None, caption=None, tableId=None, connected=True, **kwa
225225
css = kwargs.pop("css")
226226
tags = kwargs.pop("tags")
227227

228+
# Only display the table if the rows fit on one 'page'
229+
if "dom" not in kwargs and len(df) <= 10: # the default page has 10 rows
230+
if "lengthMenu" not in kwargs or len(df) <= min(kwargs["lengthMenu"]):
231+
kwargs["dom"] = "t"
232+
228233
if caption is not None:
229234
tags = '{}<caption style="white-space: nowrap; overflow: hidden">{}</caption>'.format(
230235
tags, caption

itables/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""ITables' version number"""
22

3-
__version__ = "1.4.2"
3+
__version__ = "1.4.3"

0 commit comments

Comments
 (0)