Hey all,
I am trying to make a drop-down in my registration form show me all the names of Users in my Users table which have “is_teacher” set to True. I return the Row Objects of all the users which match that criteria to my client-side form code, and then I extract the names of the users who match the “is_teacher==True” flag. All is well and good.
But the problem is that it isn’t linked back to the table now. ie, the user selects one of the names in the drop-down, and how do we link that back to the Row Object without doing another search() request? It seems it would be easier to have the items property of the drop-down linked to a row object, but only display the name value.
However, during the “change” event of the drop-down, I’d like to get that corresponding Row object that was selected so I can manipulate it (in my case, link a selected Teacher to a Student user in my database so that I know which student has which teacher.
Here is my client-side code:
def form_show(self, **event_args):
teachers = [r for r in anvil.server.call('get_teachers')]
self.drdWhichTeacher.items = [r['name'] for r in teachers]
def drdWhichTeacher_change(self, **event_args):
print("???")
##on the server side:
@anvil.server.callable
def get_teachers():
return app_tables.users.search(is_teacher=True)