I’m new to anvil and python as a whole. I’m trying to make it so when a button is clicked a specific point in the data table is edited or an element’s property is set to a specific item in a data table. I can’t figure out how to target and edit a specific cell in the table (i.e. target a value at this row and this column).
I’m sure there’s a simple solution, but I couldn’t find anything that solved my issue. Any help is appreciated!
If you haven’t already been through some of the tutorials, you should give them a try. Especially the News Aggregator tutorial: Anvil | Build Database-Backed Apps
That’ll walk you through the whole range of data table operations, including updating values in rows.
Yes definitely go with the tutorials. They will teach you the basic ideas.
Essentially what you will learn to do from them is:
Search your table for a specific row by looking for some data in that row that matches what you want to work on. This row will be turned into a variable that is a row object.
Edit that row object by specifying what column (by its name) in that row you would like to change, and what you would like to change it to.
First off, thanks for letting me know about that I had no idea the tutorials existed, however I can’t seem so solve my issue. It’s very possible I’m just a complete idiot, but here is the code returning the error:
Essentially I am trying to update the text of the like button to the amount of likes in the last row of the data table. Based on what I understand from the tutorials, I’d think this is correct, but I guess not.
The real burning question is why does it have to be only the last row that holds this ‘like count’ value?
What would happen if you had 2 users using the app at the same time?
Instead of telling the system ‘just give me the last blah blah’ it might be better to label the data in the database with a column, and probably add another that stamps the created and or last-modified time as well.
This way you can sort by time, or search by some sort of label, or both.
Yes using the article you sent earlier I just found a better way of doing this by using the upload time. Thanks so much for your help and apologies for being ignorant about these things haha
You will find we are very helpful here, but our goal is to get you to figure it out for yourself. Bombarding you with a bunch of code we wrote to fix your problem won’t teach you how to use anvil beyond the next few minutes.