AG Grid Enterprise also supports Range Selection. See the Range Selection page in the AG Grid docs for more details.
In AG Grid Community, you can enable regular text selection as if the grid were a regular table. Add the following to dashGridOptions
:
dag.AgGrid(
dashGridOptions={"enableCellTextSelection": True, "ensureDomOrder": True},
# other props...
)
With enableCellTextSelection
set to True
, you can now select text in the grid:
To see more on copying rows to the clipboard using the dcc.Clipboard
component, see
import dash_ag_grid as dag
from dash import Dash, html, dcc
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")
app = Dash(__name__)
grid = dag.AgGrid(
id="text-selection-example",
rowData=df.to_dict("records"),
columnDefs=[{"field": i} for i in df.columns],
columnSize="sizeToFit",
defaultColDef={"minWidth":125},
dashGridOptions={"enableCellTextSelection": True, "ensureDomOrder": True},
)
textarea = dcc.Textarea(
placeholder="paste area",
style={"width": "100%", "height": 200},
)
markdown = dcc.Markdown(
"Example of using a regular text selection as if the grid were a regular table"
)
app.layout = html.Div(
[markdown, grid, textarea],
style={"margin": 20},
)
if __name__ == "__main__":
app.run(debug=True)
Example of using a regular text selection as if the grid were a regular table