Close Menu
    Trending
    • How to Access NASA’s Climate Data — And How It’s Powering the Fight Against Climate Change Pt. 1
    • From Training to Drift Monitoring: End-to-End Fraud Detection in Python | by Aakash Chavan Ravindranath, Ph.D | Jul, 2025
    • Using Graph Databases to Model Patient Journeys and Clinical Relationships
    • Cuba’s Energy Crisis: A Systemic Breakdown
    • AI Startup TML From Ex-OpenAI Exec Mira Murati Pays $500,000
    • STOP Building Useless ML Projects – What Actually Works
    • Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025
    • The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Machine Learning»How to Embed Clickable links in ag-Grid Columns within Streamlit — 2025 | by Pon Dinesh Kumar M | Jan, 2025
    Machine Learning

    How to Embed Clickable links in ag-Grid Columns within Streamlit — 2025 | by Pon Dinesh Kumar M | Jan, 2025

    Team_AIBS NewsBy Team_AIBS NewsJanuary 24, 2025No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Embed Clickable Hyperlinks in ag-Grid Columns with Streamlit

    Hey there, tech lovers and Streamlit aficionados! At this time, I’m right here to demystify a typical question buzzing round within the Streamlit neighborhood: How do you flip cells in an ag-Grid desk into clickable hyperlinks? The reply is less complicated than you would possibly suppose, and I’m going to stroll you thru it in a two-step course of. By the tip of this put up, your Streamlit app’s ag-Grid won’t solely show information but additionally function a gateway to extra data with only a double-click. So, let’s dive in!

    Step one is to arrange your grid choices with a handler for double-click occasions. This may permit us to outline what occurs when a consumer double-clicks a cell. Right here’s how you are able to do it:

    # Create an occasion of the grid choices builder
    gb = GridOptionsBuilder.from_dataframe(your_dataframe)
    # Configure grid choices
    gb.configure_grid_options(
    onCellDoubleClicked=JsCode(onCellDoubleClickedHandler),
    autoSizeStrategy={"kind": "fitGridWidth"}
    )
    # Go the grid choices to AgGrid
    AgGrid(your_dataframe, gridOptions=gb.construct())

    On this snippet, we’re utilizing the GridOptionsBuilder to create grid choices from our dataframe. We then configure these choices to pay attention for the onCellDoubleClicked occasion and cross our handler operate. The autoSizeStrategy is about to 'fitGridWidth', guaranteeing our columns neatly match throughout the grid’s width.

    Subsequent, we write the JavaScript operate that may deal with the double-click occasion. This operate will examine which column was clicked and, if it matches our standards, open a brand new browser tab with the required URL.

    onCellDoubleClickedHandler = JsCode("""
    operate (params) {
    var COLUMN_NAME = 'your_column_name'; // Column you wish to make clickable
    var URL = params.information.your_url_field; // Area that accommodates the URL
    if (params.column.colId === COLUMN_NAME && URL) {
    window.open(URL, '_blank');
    }
    }
    """)

    Right here, change 'your_column_name' with the precise title of the column you wish to flip right into a hyperlink. Equally, your_url_field must be the title of the sphere that accommodates the URL you wish to open.

    That’s all there may be to it! With these two steps, you can also make a number of columns in your ag-Grid clickable.

    • To deal with a number of columns, embody extra if situations throughout the JavaScript operate.
    • Guarantee you have got imported all the required packages earlier than implementing this resolution.
    • In case you encounter any points or have a extra elegant resolution, be happy to share it within the feedback. Your contribution may very well be invaluable to the neighborhood!

    With this fast repair, you may improve the interactivity of your Streamlit app and supply a extra intuitive consumer expertise. Now, your ag-Grid isn’t just a static desk however an interactive element that may lead customers to extra in-depth sources with a easy double-click.

    Bear in mind, the most effective options are sometimes the best ones. Hold coding, preserve streamlining, and till subsequent time, blissful coding! 🚀



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleMeta to Increase Spending to $65 Billion This Year in A.I. Push
    Next Article How Chinese company DeepSeek released a top AI reasoning model despite US sanctions
    Team_AIBS News
    • Website

    Related Posts

    Machine Learning

    From Training to Drift Monitoring: End-to-End Fraud Detection in Python | by Aakash Chavan Ravindranath, Ph.D | Jul, 2025

    July 1, 2025
    Machine Learning

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025
    Machine Learning

    Why PDF Extraction Still Feels LikeHack

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    How to Access NASA’s Climate Data — And How It’s Powering the Fight Against Climate Change Pt. 1

    July 1, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    Is Acquiring a Business Right For You? Here’s How to Know If You Should Buy a Business or Start From Scratch

    January 17, 2025

    Run deepseek R1 Locally!. Explanation of FAQ’s and installation… | by Abdullah Javed | Jan, 2025

    January 30, 2025

    How Data Engineering is Saving Lives: The Healthcare Data Revolution | by Junaid Mohammed | Feb, 2025

    February 7, 2025
    Our Picks

    How to Access NASA’s Climate Data — And How It’s Powering the Fight Against Climate Change Pt. 1

    July 1, 2025

    From Training to Drift Monitoring: End-to-End Fraud Detection in Python | by Aakash Chavan Ravindranath, Ph.D | Jul, 2025

    July 1, 2025

    Using Graph Databases to Model Patient Journeys and Clinical Relationships

    July 1, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.