Synphonyte / leptos-struct-table

Easily create Leptos table components from structs
Apache License 2.0
164 stars 24 forks source link

Table rows aren't rendered properly after 500 rows #41

Closed dt-pa closed 4 months ago

dt-pa commented 4 months ago

slight modification on this example:

The expected result is 3 pages of dummy entries, but the 3rd page is empty

#[derive(Debug, Clone, Serialize, Deserialize, TableRow)]
#[table(sortable, impl_vec_data_provider)]
struct Struct {
    id: usize,
    name: String,
}

#[component]
pub fn MyComponent() -> impl IntoView {
    let page_controller = PaginationController::default();
    let current_page = page_controller.current_page;
    let mut data = Vec::with_capacity(800);
    for i in 0..800 {
        data.push(Struct {
            id: i,
            name: "Dummy".into(),
        })
    }
    let max_page = move || 2;
    let table_content = move || {
        view! {
            <TableContent
                rows={data.clone()}
                display_strategy={
                    DisplayStrategy::Pagination {
                        row_count: 250,
                        controller: page_controller
                    }
                }
            />
        }
    };
    view! {
        <table>
            {table_content}
        </table>
        <button on:click={move |_| {current_page.set(0)}}>First</button>
        <button on:click={move |_| {page_controller.previous()}}>Prev</button>
        <button on:click={move |_| {
            if current_page.get_untracked() < max_page() {
                current_page.update(|page| *page += 1);
            }
        }}>
        Next
        </button>
        <button on:click={move |_| {
            current_page.set(max_page());
        }}>Last</button>
        <div>
            <span style="padding: 3px;">{move || current_page.get() + 1}</span>
            /
            <span style="padding: 3px;">{move || max_page() + 1}</span>
        </div>
    }
}