Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DataTable showing the last page #225

Merged
merged 3 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions assets/data_table/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ function App({ ctx, data }) {
const height = totalRows >= 10 && infiniteScroll ? 440 + headerHeight : null;
const rowMarkerStartIndex = (content.page - 1) * content.limit + 1;
const minColumnWidth = hasSummaries ? 150 : 50;

const rows =
content.page === content.max_page && !infiniteScroll
? totalRows % content.limit
aleDsz marked this conversation as resolved.
Show resolved Hide resolved
: content.limit;
const rows = content.page_length;

const drawHeader = useCallback((args) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion lib/assets/data_table/build/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/kino/data_table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ defmodule Kino.DataTable do
{:suspended, {items, 0}, continuation} ->
{Enum.reverse(items), amount, continuation}

{:halted, {items, left}} ->
{Enum.reverse(items), amount - left, nil}

{:done, {items, left}} ->
{Enum.reverse(items), amount - left, nil}
end
Expand Down
1 change: 1 addition & 0 deletions lib/kino/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ defmodule Kino.Table do
rows: rows,
columns: columns,
page: ctx.assigns.page,
page_length: length(rows),
max_page: total_rows && ceil(total_rows / ctx.assigns.limit),
total_rows: total_rows,
order: ctx.assigns.order,
Expand Down