Python 3.12.10, Streamlit 1.50, running locally in Windows. Not deployed to server.
I’ve got a st.data_editor with 3 link columns for “edit”, “duplicate”, “delete” actions. Each row represents a query. The links have the operation name and query_name as a URL parameter. When such a link is clicked on, a new browser tab is opened. I don’t see an obvious way in the API to keep the browser on the same streamlit page in its own browser tab. I’ve tried st.dataframe, st.aggrid, and st.Data_editor thus far.
The edit link brings up an edit form in an st.dialog and the duplicate link copies the row and opens the edit dialog on the duplicate row. If I try to edit 10 rows in one session, I’ll have 10 copies of the particular Streamlit page. Is there a way to control the target of a link somehow?
The dialog form has several long text fields so it’s not practical to edit directly in the grid. I’m open to any solution.
def render_queries_table(
queries: List[Dict[str, object]],
filtered_pairs: Sequence[Tuple[int, Dict[str, object]]],
row_limit: int,
) -> bool:
if not filtered_pairs:
st.info("No queries match the current filters.")
return False
display_data = []
for orig_idx, query in filtered_pairs:
query_name = query.get("name", "")
row = {
"name": query_name,
"type": query.get("type", "misc"),
"description": query.get("description", ""),
"category": query.get("category", ""),
"enabled": query.get("enabled", False),
"edit": f"?edit={query_name}",
"duplicate": f"?duplicate={query_name}",
"delete": f"?delete={query_name}"
}
display_data.append(row)
display_df = pd.DataFrame(display_data)
edited_df = st.data_editor(
display_df,
column_config={
"name": st.column_config.TextColumn("Name"),
"type": st.column_config.SelectboxColumn("Type", options=["error", "inventory", "misc"], required=True),
"description": st.column_config.TextColumn("Description"),
"category": st.column_config.TextColumn("Category"),
"enabled": st.column_config.CheckboxColumn("Enabled"),
"edit": st.column_config.LinkColumn("✏️", help="Click to edit", width=40, display_text="✏️"),
"duplicate": st.column_config.LinkColumn("📋", help="Click to duplicate", width=40, display_text="📋"),
"delete": st.column_config.LinkColumn("🗑️", help="Click to delete", width=40, display_text="🗑️"),
},
column_order=["name", "type", "description", "category", "enabled", "edit", "duplicate", "delete"],
num_rows="fixed",
hide_index=True,
height=int(row_limit * 35 + 40),
disabled=["name"],
)