How to get selected rows from qgrid in pyshiny

I'm using qgrid with pyshiny and I would like to detect what rows are selected in qgrid when the user presses a button:

from shiny import App, render, ui, reactive
import pandas as pd
from shinywidgets import *
import qgrid

app_ui = ui.page_fluid(
    output_widget("mytable"),
    ui.input_action_button("doSomething", "Do Something")
    )

def server(input, output, session):
    from pandas_datareader.data import get_data_yahoo
    spy = get_data_yahoo(
        symbols='SPY',
        start=pd.Timestamp('2011-01-01'),
        end=pd.Timestamp('2014-01-01'),
        adjust_price=True,
    )

    @output
    @render_widget
    def mytable():
        return qgrid.show_grid(spy)

    @reactive.Effect
    @reactive.event(input.doSomething)
    def doSomething():
        #do something with selected rows
        print("click")

app = App(app_ui, server)

How do I get the selected rows from mytable?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.