To upload files, please first save the app
import streamlit as st
import pandas as pd
import json
from st_aggrid import AgGrid, GridOptionsBuilder
from code_editor import code_editor
@st.cache_data
def get_data():
return pd.read_json("https://www.ag-grid.com/example-assets/olympic-winners.json")
df = get_data()
gd = GridOptionsBuilder().from_dataframe(df)
gd.configure_selection(selection_mode="multiple", use_checkbox=True)
gridOptions = gd.build()
tabs = st.tabs(['Grid', 'GridOptions', 'AgGridReturn.selected_data'])
with tabs[0]:
response = AgGrid(df, gridOptions, key='grid1')
with tabs[1]:
text = code_editor(
json.dumps(gridOptions, indent=4),
lang="json",
props={'readOnly': False},
height='300px'
).get('text', '')
if text != '':
gridOptions = json.loads(text)
with tabs[2]:
selected_data = response.selected_data
if selected_data is None:
st.write('Nothing was selected!')
else:
st.write(response.selected_data)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?