Comments (3)
Hello,
With the use of Streamlit cache, you can add a button that append a row to the input dataframe of AfGrid() :
import streamlit as st
import pandas as pd
from pandas.api.types import is_bool_dtype, is_numeric_dtype
from st_aggrid import AgGrid, GridOptionsBuilder
def get_blank_from_dtype(dtype):
"""Return correct values for the new line: 0 if column is numeric, "" if column is object, ..."""
if is_numeric_dtype(dtype):
return 0
elif is_bool_dtype(dtype):
return False
else:
return ""
# Initialize your dataframe
if "df_for_grid" not in st.session_state:
st.session_state.df_for_grid = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
add_row = st.button("➕ Row")
if add_row:
st.session_state.df_for_grid = st.session_state.changed_df.append(
pd.Series(
[
get_blank_from_dtype(dtype)
for dtype in st.session_state.df_for_grid.dtypes
],
index=st.session_state.df_for_grid.columns,
),
ignore_index=True,
)
gb = GridOptionsBuilder.from_dataframe(st.session_state.df_for_grid)
gb.configure_default_column(editable=True)
gridOptions = gb.build()
grid = AgGrid(
st.session_state.df_for_grid,
gridOptions=gridOptions,
)
st.session_state.changed_df = grid["data"]
from streamlit-aggrid.
I'm looking forward to see this functionality in place. Would be very useful.
any way to include similar buttons on top of the table as in this link: [https://www.ag-grid.com/javascript-data-grid/data-update-transactions/](https://www.ag-grid.com/javascript-data-grid/data-update-transactions/).
from streamlit-aggrid.
I would love this feature as well! It would be pretty awesome.
from streamlit-aggrid.
Related Issues (20)
- Aggrid element sometime not displaying with multiple expanders
- ColumnsAutoSizeMode.FIT_CONTENTS not work in second tab of st.tabs
- "agLargeTextCellEditor"最大字符限制
- AgGrid Import crashes Pycharm Debugger
- grand totals at bottom of columns HOT 4
- How to enable cellClassRules? HOT 1
- Change "In Range" Date Column Functionality HOT 1
- Question: Is there a way for the JsCode to call python code? HOT 4
- Artefacts on the table corners present when using dark streamlit themes
- Table not displaying upon browser refresh
- Unstable grid display HOT 4
- Row selection events not reported HOT 14
- Browser tab hangs when (async) refreshing streamlit pages HOT 3
- Implementation of getGroupRowAgg callback for multiple columns HOT 1
- 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
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.