I’m doing something wrong, it has something to do with creating or using mapping that I just don’t understand.
I use the single asterisk because that is what i think the docs call to use. but I’m wrong because that is a list, So I tried the ** and get error that the object is not a mapping. So I take out the asterisks and I am back to missing a positional argument.
def category_box_change(self, **filtered_args):
“”“This method is called when an item is selected”""
category = self.category_box.selected_value
genres = anvil.server.call(‘get_genres’,*category)
self.genre_box.items = genres
alert(categories)
I’ve split your post into a new topic because I’m not 100% sure it’s directly related to the original topic of filtering a data table search.
Providing a bit more context or a clone link will help others to help you. What is get_genres doing? What type of value is category? You can read more about *args and **kwargshere which should help you make some progress.
I have categories table with two categories (Fiction and Non Fiction) and a genre table that is populated with genres linked to each. For example: Mystery : Fiction, Biography : Non Fiction.
In my app I have two drop down boxes Category and Genre. I am using get_genre to filter the genre drop down depending on which category is selected.
This morning I added a data binding to the genre drop down and am getting a new error. Which I’m optimistically taking as progress but probably isn’t.
Here is the new error.
anvil.tables.TableError: Invalid argument to table query: "Fiction"
In your function get_genres, is filtered_args a dict containing key (which is the name of the column) and value (which is the value to search in that column)?
If so, your function should be:
genres = [(gen['genre'], gen) for gen in app_tables.genres.search(**filtered_args)]
return genres
Considering that your genre table has a column name Category and that one of the values in the Category column is Fiction, your filtered_args should be like this to search for genres in the Fiction category:
I was just coming to say I figured it out. I was way over thinking it and went back to basics. Just what you outlined and it worked like a charm. Thanks for taking the time to help.