Bijoy
November 4, 2023, 3:45am
1
Hi community friends,
I have a requirement of displaying 10 million rows and 100 columns using Dash-ag-grid in the browser with 8 dcc.Dropdowns to filter in addition to filter in the dash-ag-grid.
I have tried pagination, preset pag# but its very slow and takes a very longtime.
Dash-ag-grid 0.34 has pagination issues too. Right?
Can someone help me out with this?
Thank you very much,
BKS
Liripo
November 4, 2023, 9:57am
2
Hello @Bijoy ,
You can try pagination with rowModelType infinite.
Here you go, using the api:
from dash import Dash, html, Input, Output, no_update, State, ctx
from dash_ag_grid import AgGrid
import dash_mantine_components as dmc
import pandas as pd
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
)
app = Dash()
# basic columns definition with column defaults
columnDefs = [{"field": c} for c in df.columns]
app.layout = html.Div(
[
AgGrid(
id="grid",
colâŚ
@Bijoy
You can find a lot more information on handling large files with the Infinite Row Model in the docs:
https://dash.plotly.com/dash-ag-grid/infinite-row-model
Bijoy
November 10, 2023, 7:05am
5
@ Liripro,
Thank you very much. Your reference really helped me put together the Dash App in Polars format.
Best,
Bijoy
Bijoy
November 10, 2023, 7:09am
6
Hello @jinnyzor ,
Awesome! That was perfect!! The only change I made is I adapted it to Polars since it is blazing fast. Please see below:
@app.callback (
Output(âgridâ, âgetRowsResponseâ),
Input(âgridâ, âgetRowsRequestâ),
State(âfiltersâ, âvalueâ),
)
def update_grid(request, filters_data):
if request:
filtered_df = df.filter(df[âcolnameâ] == filters_data)
partial = filtered_df.slice(request["startRow"], request["endRow"] - request["startRow"])
return {"rowData": partial.to_pandas().to_dict("records"), "rowCount": len(filtered_df)}
Thank you very much! Appreciate it a ton!
Best,
BIjoy
Bijoy
November 10, 2023, 7:12am
7
Hi @AnnMarieW ,
I would like to express my sincere gratitude for all the help and support you have given to the community members who are ardent fans of Dash & Plotly!
Thank you very much for the references. It helped me figure the solution quick.
Best,
Bijoy
1 Like