How to set paginationSetPageSize with ui.select? #312
-
Hi, I have searched the whole GitHub repo, also for similar stuff, however, unfortunately I can't get it to work. I want to be able to change the number of rows with a select input. This code: # Default:
_value = 10
ui.select(
[10, 25, 50, 100],
value=_value,
on_change=lambda e: rank_table.call_api_method(
f"paginationSetPageSize(Number({e.value}))"
# https://ag-grid.com/javascript-data-grid/grid-api/#reference-pagination-paginationSetPageSize
),
)
rank_table = ui.table(
{
"paginationPageSize": _value,
"pagination": True,
"domLayout": "autoHeight",
}
) results in this error in browser console: Uncaught TypeError: this.gridOptions.api[name] is not a function
at Proxy.call_api_method (table:48:33) Hopefully some pro can help me? :-D Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I am not giving up and tested another way: First I tried with a button and hardcoded value: async def page_size():
await ui.run_javascript(
f"getElement({rank_table.id}).gridOptions.api.paginationSetPageSize(Number(100))",
respond=False,
)
ui.button("100", on_click=page_size) Well, this worked. Then I wanted to make it a bit more nicer and dynamic: async def page_size(value):
await ui.run_javascript(
f"getElement({rank_table.id}).gridOptions.api.paginationSetPageSize(Number({value}))",
respond=False,
)
ui.select(
[10, 25, 50, 100],
on_change=lambda e: page_size(e.value),
) Table page size ist not changing with this one... |
Beta Was this translation helpful? Give feedback.
-
rank_table.call_api_method('paginationSetPageSize', e.value) Sorry, we really need to add documentation to these methods... |
Beta Was this translation helpful? Give feedback.
-
Well, you don't have to apologize! This is a really great and huge project! Thanks. |
Beta Was this translation helpful? Give feedback.
call_api_method
expects the method name and arguments separately:Sorry, we really need to add documentation to these methods...