Displaying specific indices of a returned data table search in repeating panel

Hello everyone,

I tried to dig around the documentation and forum but couldn’t quite figure out a solution to my problem. What I am trying to do is display items in a repeating panel as a group of corresponding points are selected on a plot. In plotly, there is a function call for selecting multiple points, which returns an array called [points] that corresponds to the row index in the returned table search.

So for example what I get after selecting a bunch of points on the plot is a [points] array that looks like:
[1,2,3,4,5,15,20,24]

I want to take this array of indices and create a new table with just these rows from a table that was already searched. So I have an initial table query that looks like this:

# Initial data table search
self.samples = self.samples_master.search()

Later on, I want to create a new table that is effectively self.samples[points], which further refines the self.samples table to only include the items from the points array.

I have tried:

def plot_1_select(self, points, **event_args):
     self.repeating_panel_2.items = self.samples[points]

and get the following error:

Exception: Indexing with [] is not supported on this anvil.tables.SearchIterator

My question is, how can I refine my self.samples table to only include the row indices as outlined in the [points] array, and then push this to update a repeating panel? Sorry if this is trivial, I can’t seem to get it right.

Thanks in advance community!

Ethan

Well made a silly mistake! The [points] array that is returned from plotly is actually a dictionary that needs to be unpacked. For each point there is a “point_number” item that needs to be appended to an array. This code solved my problem:

def plot_1_select(self, points, **event_args): 
    index_array = [point['point_number'] for point in points] 
    self.repeating_panel_2.items = [self.samples[i] for i in index_array]