Infinite Scrolling
Append rows from a callback when the user scrolls to the bottom edge of a fixed-height table.
Infinite Scrolling
Append rows from a callback when the user scrolls to the bottom edge of a fixed-height table.
Source: usage.py::build_infinite_scrolling_code().
table = (
dmdt.DataTable(
id="infinite-scroll-table",
data=INFINITE_SCROLL_RECORDS[:INFINITE_SCROLL_BATCH_SIZE],
columns=INFINITE_SCROLL_COLUMNS,
paginationMode="none",
)
.update_layout(
radius="lg",
withTableBorder=True,
height=300,
)
)
@callback(
Output("infinite-scroll-table", "data"),
Input("infinite-scroll-table", "scrollEdge"),
State("infinite-scroll-table", "data"),
)
def load_more_rows(scroll_edge, current_rows):
if scroll_edge and scroll_edge.get('edge') == 'bottom':
next_size = len(current_rows or []) + INFINITE_SCROLL_BATCH_SIZE
return INFINITE_SCROLL_RECORDS[:next_size]
return current_rows