Hi,
Is there a way to hide column headers with streamlit-aggrid.
Thanks
Hi,
Is there a way to hide column headers with streamlit-aggrid.
Thanks
ob = GridOptionsBuilder.from_dataframe(df)
ob.configure_column("Details", hide=True)
See this post too.
Hi,
Thank you for your response.
I tried the following solution but it did not work. I still see the column headers in the grid.
Thanks
Prerna
Could you provide a minimal and simplified version of the code where you are encountering issues?
Hi,
Please see below code. I am creating a grid to display the totals but I do not want the columns in the âDelivered_Total_dfâ to be displayed. I only want the values but it still shows the header
delivered_totals_df = grid_df.loc[grid_df[âorder_created_yearâ] == âtotal:â]
delivered_totals_df=delivered_totals_df[[âeto_delivered_countâ,âgross_ch_delivered_revenueâ,âgross_ch_delivered_costâ, âgross_ch_delivered_marginâ,âavg_order_life_span_in_daysâ]].copy()
delivered_totals_df = delivered_totals_df.iloc[[-1]]
delivered_totals_df.insert(0, " ", âTotalâ)
options1 = GridOptionsBuilder.from_dataframe(delivered_totals_df)
options1.configure_column(âDetailsâ, hide=True)
options1.configure_side_bar()
options1.configure_selection(âsingleâ)
options1.configure_column(âgross_ch_delivered_revenueâ, header_name=None, cellStyle={âtext-alignâ: âcenterâ})
options1.configure_column(âgross_ch_delivered_costâ, header_name=None, cellStyle={âtext-alignâ: âcenterâ})
options1.configure_column(âeto_delivered_countâ, header_name=None, cellStyle={âtext-alignâ: âcenterâ})
options1.configure_column(âgross_ch_delivered_marginâ, header_name=None, cellStyle={âtext-alignâ: âcenterâ})
options1.configure_column(âavg_order_life_span_in_daysâ, header_name=None, cellStyle={âtext-alignâ: âcenterâ})
AgGrid(delivered_totals_df, height=min(MIN_HEIGHT+len(delivered_totals_df)*ROW_HEIGHT, MAX_HEIGHT), fit_columns_on_grid_load = True,gridOptions=options1.build(), allow_unsafe_jscode=True,)
Thanks
Prerna
Sorry the solution I give is wrong. It will hide the entire column. Let me think of other ways.
Have a look at this example, it will sort of hide the column header Country
.
from st_aggrid import GridOptionsBuilder, AgGrid
import pandas as pd
df = pd.DataFrame({'Country': ['Japan', 'Norway'],
'Capital': ['Tokyo', 'Oslo']})
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_column('Country', header_name='')
AgGrid(df, gb.build())
Hi @prerna108
You can hide all your aggrid headers like this:
import streamlit as st
from st_aggrid import GridOptionsBuilder, AgGrid
import pandas as pd
df = pd.DataFrame({'Country': ['Japan', 'Norway'], 'Capital': ['Tokyo', 'Oslo']})
gb = GridOptionsBuilder.from_dataframe(df)
gridOptions = gb.build()
gridOptions["headerHeight"]=0
AgGrid(df, gridOptions)
Cheers