Slicing data table

What I’m trying to do:
I am trying to slice data table to exclude some first rows.

Code Sample:

@anvil.server.callable
def get_articles_to_label(query,table):
  result =  app_tables.table.search()
  result = result[50:]
  return result

Getting error message
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize <class 'anvil._server.LiveObjectProxy.Iter'> object at msg['response']

I think the issue here is the result is an iterrator and not a list.

Try wrapping the search with list()

@anvil.server.callable
def get_articles_to_label(query,table):
  result =  list(app_tables.table.search())[50:]
  return result

You could return the search iterator and do the slicing client side.

3 Likes