Comments (1)
In complement, in case of nested table, I cannot fin a way go get the nested re-ordering. I get the eddition but not the re-order.
Here a made a few changed on the nested table example
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode, GridUpdateMode, DataReturnMode
import pandas as pd
import numpy as np
import requests
url = "https://www.ag-grid.com/example-assets/master-detail-data.json"
r = requests.get(url)
data = r.json()
df = pd.read_json(url)
df["callRecords"] = df["callRecords"].apply(lambda x: pd.json_normalize(x))
type_dropdownlist = ('Short', 'Long')
gridOptions = {
# enable Master / Detail
"masterDetail": True,
"rowSelection": "multiple",
# the first Column is configured to use agGroupCellRenderer
"columnDefs": [
{
"field": "name",
"cellRenderer": "agGroupCellRenderer",
"checkboxSelection": True,
},
{"field": "account"},
{"field": "calls"},
{"field": "minutes", "valueFormatter": "x.toLocaleString() + 'm'"},
],
"defaultColDef": {
"flex": 1,
},
# provide Detail Cell Renderer Params
"detailCellRendererParams": {
# provide the Grid Options to use on the Detail Grid
"detailGridOptions": {
"rowDragManaged": True,
"rowDragEntireRow": True,
"rowDragMultiRow": True,
'animateRows': True, "rowDragMultiRow": True,
"columnDefs": [
{"field": "callId", "editable":False, "rowDrag":True,"rowDragManaged":True, "rowDragEntireRow":True},
{"field": "direction"},
{"field": "number", "minWidth": 150},
{"field": "duration", "valueFormatter": "x.toLocaleString() + 's'"},
{"field": "switchCode", "minWidth": 150},
{"field" : 'calltype', "editable":True, "cellEditor":'agSelectCellEditor',
"cellEditorParams":{'values': type_dropdownlist}, "singleClickEdit":True}
],
"defaultColDef": {
"sortable": True,
"flex": 1,
},
},
# get the rows for each Detail Grid
"getDetailRowData": JsCode(
"""function (params) {
params.successCallback(params.data.callRecords);
}"""
),
},
"rowData": data
}
tabs = st.tabs(["Grid", "Underlying Data", "Grid Options", "Grid Return"])
with tabs[0]:
r = AgGrid(
None,
gridOptions=gridOptions,
allow_unsafe_jscode=True,
enable_enterprise_modules=True,
update_mode=GridUpdateMode.GRID_CHANGED,
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
key="an_unique_key",
)
with tabs[1]:
st.write(data)
with tabs[2]:
st.write(gridOptions)
# tabs = st.tabs(['Selected Rows','gridoptions','grid_response'])
# with tabs[0]:
st.write(r.get("selected_rows"))
st.json(r.get("selected_rows").to_json(orient="records", indent=2))
from streamlit-aggrid.
Related Issues (20)
- Add Tooltips when Hovering on Cells or Headers HOT 2
- Can't pickle local object 'GridOptionsBuilder.__init__.<locals>.ddict' HOT 1
- [Q] Can I get the selected cell position (row & column) from the response object? HOT 2
- Width statement in columnDefs of grid options is ignored HOT 3
- Question/improvement: How to realize what event from grid occurs? HOT 4
- Show Ag-Grid Version HOT 1
- Reselect of rows on re-runs doesn't work HOT 1
- Resource Warning
- aggrid with fastapi request HOT 3
- pre_select_all_rows not functional
- The phantom event appears after st.rerun()
- AttributeError: module 'streamlit.components.v1' has no attribute 'components' HOT 2
- Is there a text column filter? HOT 1
- How to implement quickfilter after enable_quicksearch is deprecated? HOT 1
- Can aggrid add a row of cells?
- [Question] Why Altair is <5?
- Quicksearch filter + Row area + Pagination = height clipping
- From a beginner:A nested table program error
- Websocket: Client -> Server: Big size, causes excecution / reruns to slow down
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streamlit-aggrid.