Hello Everyone,
I am trying to make a simple recipe management tool as a proof of concept and i am trying to get the linked data in the ingredients data table to show up on the data grid i have. Currently i am only able to display this:
The tables look like this:
recipes
recipe_name | description | instruction
the ingredients table has the linked recipe name, count, measurement name, and ingredient
the data binding is set to this on the data grid for the label associated with the recipe name: self.item[‘Recipe_Name_link’]
I have been following this tutorial to try and troubleshoot where i may have gone wrong. https://anvil.works/learn/tutorials/data-grids/getting-started
Any suggestions on how to get the linked name in the ingredients table to show up on the data grid?
Thank you for the help
Hello and welcome,
Please see this post for a similar issue.
Your screenshot indicates that you are displaying the row object rather than the data “inside” the row object. Linked rows can be confusing at first, but basically you need to index to get inside of them. Example,
# assuming this is from a table where "reciepe_rows" is a column with the type "link to a single row".
# That is, this column is a link to a single row from another table.
# here I'm now extracting the "receipe_name" text from the linked row
row['receipe_rows']['receipe_name']
I’m going from memory here, so please see the post that I linked to above.
Thank you for the reply. Sadly i am not doing single row link, as every recipe can have multiple ingredients. It is a many (ingredients) to one (recipe). I applied your update as suggested and get this:

I am guessing data grids are not good for many to 1 relationships?
Oh okay. If you have a multi-link then you essentially have a list to deal with.
You may search the forum and docs for “multiple linked columns” or something along those lines. For example,
row['receipe_rows'][1]['receipe_name']
would extract the text from the second linked row.
Good luck!