Streamlit Ag-Grid
AgGrid is a JavaScript-based grid type that is very simple to use, fast and very fancy for your Python web applications using Streamlit, but with very limited flexibility.
Streamlit AgGrid is an open source grid created by Pablo Fonseca that includes enterprise features, but you can use stylish graphs and tables at no cost.
By using the link, you can access many table types and codes that can be made with AgGrid.
Now we will examine how AgGrid is used by making an example.
We need to import the following libraries to make a mutable and interactive table. We will explain how to use it in the following pages.
Since AgGrid is a JavaScript-based grid, the background properties of columns or cells can be changed by adding JavaScript code to the Python code. I am adding the JsCode library to be able to use JS code in the Grid.
It is important to include the GridOptionsBuilder library. Because it provides AgGrid configuration with the methods in it. Some of the methods included are as follows.
- configure_columns
- configure_selection
- configure_pagination
- configure_grid_options
In the code snippet below, firstly, the GridOptionsBuilder object is created with the dataframe read from a local csv file.
We are using GridOptionsBuilder to decide which columns are editable, checkbox is used or multi selection is allowed.
After making the necessary adjustments with the GridOptions Builder, we can create the Ag Grid object and make it appear on the screen like below.
After the user makes the necessary updates, the current dataframe in AgGrid is retrieved as follows:
We can also get the selected lines using the following lines of code:
You can test and examine many features of Ag Grid live from its creator in the link. Highly recommended.
For more information about Streamlit, you can visit:
Bye for now.