Skip to content

For pagination with PaginatedTableDataProvider the method get_page is called for too much page indexes and repeatedly #81

@VincentBaijot

Description

@VincentBaijot

Hello,

Thanks for this promising package. It seems awsome but when i tested it i saw one strange behavior.

I made a simple table very close to the paginated_rest_datasource example and i made it log the calles to get_page and row_count.

impl PaginatedTableDataProvider<Game> for GamesDataProvider {
    const PAGE_ROW_COUNT: usize = 20;

    async fn get_page(&self, page_index: usize) -> Result<Vec<Game>, String> {
        log::info!("get_page {page_index}");
        if page_index == 0 {
            Ok(self.games.clone())
        } else {
            Ok(vec![])
        }
    }

    async fn row_count(&self) -> Option<usize> {
        log::info!("row_count");
        Some(self.games.len())
    }
}

And i displayed the table with this data in a page :

    let games = move || GamesDataProvider::new();

    let pagination_controller = PaginationController::default();
    let container = NodeRef::new();

    view! {
        <div class="lg:flex lg:items-center lg:justify-center m-8" node_ref=container>
            <table class="text-sm text-left text-gray-400">
                <TableContent
                    rows=games()
                    display_strategy=DisplayStrategy::Pagination {
                        controller: pagination_controller,
                        row_count: 20,
                    }
                    scroll_container=container
                />
            </table>
        </div>
    }

With the parameters above row_count 20 and PAGE_ROW_COUNT 20 then only the page with index 0 is necessary, but what i observed is that he get_page function is called for page indexes 0, 1, 2, 3, 4, then again 0, 1, 2, 3, then 0, 1, 2, then 0, 1, and finally 0.

Image

Did i misuded the api ?

I join a minimal example to reproduce the issue.
test-leptos-table.tar.gz

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions