Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

DataTable page_count always returns None

$
0
0

@OliverBrace wrote:

There seems to currently be an Issue in the Datatables where if for example:

User is in page 50 and then filters but there are now only 20 pages the user will remain at page 50 (which is now blank).

I have tried to get around this by using the filter_query to trigger a callback if page_count < page_current then set the current page to page_count.

@app.callback(
    [
        Output("calc_data_summary", "page_current"),
    ],
    [
        Input("calc_data_summary", "filter_query")
    ],
    [
        State("calc_data_summary", "page_count"),
        State("calc_data_summary", "page_current"),
    ],
)

def reset_filter_sort_on_datatable(filter, total_pages, current):
    if total_pages is None or current_page is None:
        return [1]


    if total_pages < current_page:
        return [total_pages]

    return [current_page]

However, I found that this code was never running. When I investigated I found that page_count was always returning None and therefore never got past the first if statement.

The documentation (https://dash.plot.ly/datatable/reference) says that

`page_count`  ( *number* ; optional):  `page_count`  represents 
the number of the pages in the paginated table.

I assumed this to mean that it should return the value of the total amount of pages.

Do I have this correct?

However, I have noticed that

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles