Hi! I have an error I can’t figure out. I made a message box for users to leave me feedback. I am attempting to make an interface for me to see the messages filtered by read, unread, or all. I apologize if I missed something in the documentation, but I can’t seem to crack this.
Form code:
def read_filter_go_click(self, **event_args):
"""This method is called when the link is clicked"""
if self.all_radio_button.selected == True:
read_option = self.all_radio_button.value
elif self.read_radio_button.selected == True:
read_option = self.read_radio_button.value
elif self.unread_radio_button.selected == True:
read_option = self.unread_radio_button.value
message_list = anvil.server.call('get_messages', read_option)
self.messages_repeat.items = message_list.search()
Server code here:
@anvil.server.callable
def get_messages(read_option):
if read_option == 'unread':
return app_tables.messages.client_writable(read=False)
elif read_option == 'read':
return app_tables.messages.client_writable(read=True)
else:
return app_tables.messages.client_writable()
Error:
anvil.tables.TableError: No such column 'read' in this view
while setting self.message_read_checkbox.checked = self.item['read']
in a data binding for self.message_read_checkbox
running on the server; called from update_binding.py, line 2 column 2
I added a checkbox to the read column (True/False column in the table) and it has a binding self.item[‘read’].
The error message only occurs when using the filtered options (read = True or read=False). The unfiltered option works perfectly. When filtered, it provides results filtered as expected, but the read column checkbox isn’t checked or representing the actual status.
I hope I provided enough info. Any help is appreciated. Thanks!
@chris_idc Hi there,
Is it possible for you to share a clone link for the app? I could then debug a bit easier and perhaps help out.
Just click the
icon in the IDE, “share app”, and copy the link under “share source code with others”
I can. It is definitely still a work in progress and I am a bit of a novice, so please keep that in mind 
Edit: removing the source code link. It needs more work before I am ready to have it out there more than necessary.
Thanks
Oh - the form it is on is the dashboard one
@chris_idc Okay I looked into this as it wasn’t immediately obvious to me.
It looks like .client_writable()
returns a “restricted” view. The hitch is that the view does not contain data from the column that was used as a filter.
So for example:
app_tables.messages.client_writable(read=True)
will pull back all rows where read=True
, but not data in the read
column itself, hence your error:
"No such column 'read' in this view"
Check out the documentation here and this illustrative chart. Note that the owner
column is not present in the view.
I’ll be honest, I haven’t used restricted views in my apps up till now and so I could be missing something; however, would modifying your filtered search like this suit your needs?
@anvil.server.callable
def get_messages(read_option):
if read_option == 'unread':
rows=app_tables.messages.search(read=False)
elif read_option == 'read':
rows=app_tables.messages.search(read=True)
else:
rows=app_tables.messages.search()
return rows
Then, just set the items
in your repeating panel to rows
By the way, you can see an example of all of this in a stripped down app here. Fool around with the filters in the server module to see what gets returned.
https://anvil.works/build#clone:MFURVG73RLU6IQVW=4BRRHDEC2E4SFA2GJ4WQQBLR
I hope this helps and I’m sure others will correct me if I have led you astray.
1 Like
Your solution works great. Thank you.
I’m trying to wrap my head around exactly what is happening here, but it makes a lot more sense than it did earlier. I’ll poke around in it a bit more tomorrow and hopefully understand it better.
Cheers!
1 Like