Programmatically Set Data-Table Rows to be automatically selected based on row content

Hey! I was running into trouble getting my code to work as I get an error when running it! I have that screens hotted below. Essentially I am trying to get a table to be populated dynamically with content determined by a dropdown and date range selector. I can get that successfully working however I was also trying to get it so this content that populates the table has the selection box ticked on load depending on the content of that row. I tried to do this by setting a callback output to set the selected_rows property to have the row ID for each row found to have the content I am looking for. However when doing this I get the error that the table was passed an invalid object type as it expected type ‘object’ and got a type ‘array’. I include my code and screenshots of the error thrown below.

Please note that without any of the selected_rows stuff the function and callback work perfectly so I don’t believe it’s something to do with those sections. That said please let me know if you need any more details or if I can help in any way as this has me completely stumped!



        Output("single-payroll-table", "data"),
        Output("single-payroll-table", "selected_row_ids"),
        Output("single-payroll-table", "selected_rows"),
        # Output('hidden-div-four','children')
        Input("my-button-search", "n_clicks")
        State('single-payroll-table', 'selected_rows'),
        State('single-payroll-table', 'selected_row_ids'),
def populate_pay_table(n_clicks, name, start_date, end_date,selected_rows,selected_row_ids):
            db_file_location = os.getcwd() + "/databases/main.db"

            connection = sqlite3.connect(db_file_location)
            cursor_obj = connection.cursor()

            dbf.create_table(cursor_obj, "Billing_Transactions")

            # query = "SELECT * FROM Billing_Transactions WHERE Transaction_Date >= '{}' AND Transaction_Date <= '{}'".format(start_date, end_date)
            query = "SELECT * FROM Billing_Transactions WHERE Transaction_Date >= '{}' AND Transaction_Date <= '{}' AND Clinician_Name='{}'".format(start_date, end_date,name)
            df = pd.read_sql_query(query, connection)


            queried_Dict = df.to_dict('records')

            for dict in queried_Dict:
                del dict["Source_File"]
                del dict["import_date"]
                del dict["Modifier_Code_One"]
                del dict["Modifier_Code_Two"]
                del dict["Modifier_Code_Three"]
                del dict["Modifier_Code_Four"]
                del dict["Documents_Created"]
                del dict["Units"]
                del dict["Secondary_Insuerer_Group"]
                del dict["Supervisor_NPI"]
                del dict["Clinician_NPI"]
                del dict["Bill_As_Supervisor"]
                del dict["Payment_Assigned_to_Practice"]

            for item in range(len(queried_Dict)):
                if queried_Dict[item]['is_addon'] == 'False':
            # print(queried_Dict)

            return [queried_Dict],[selected_row_ids],[selected_rows]

One other way you can try this is to use selected_row_indices instead. Use this example as a reference for what you are looking for. and you will be able to simply append row indices instead of storing an entire ID as well so it should be more data efficient if you specify the dtype.