My app allows users to view or sell items for reuse. In the home screen, all the rows from Airtable are displayed in a ListViewer showing the title of the posts. I’m working on a search function where the user inputs a string and filter through all the rows to only display rows with that title in a ListViewer. It works fine, but when the user clicks on a title to open up the next screen with the post details, I was passing the index of the listViewer but what I need to do is pass the row id that matches that post. I’m not sure how to do that, can you look at my code?
When you apply any filter, the list-viewer shows only the supported items - ex. 20 from a list of 100.
If you click on any of those, index will range from 1 - 20 & not the item’s native index. So, we need to keep track of the native indexes.
Native index = row no. of the item.
To do so, we will make the normal list a numbered list by attaching the item’s native index in start of it. And then, when any item is clicked (doesn’t matter if the list is filtered or not), the item’s native index would be it’s starting no. (we’ll crop it).
First try this idea yourself, and then reply with the result here
@manyone can you produce a working example with our blocks?
I thought that rowNum only took an integer value. What you return could be anything. The issue with that being, there could be double of that anything. Because a list may have items from multiple data sources all in one, I’m wondering if this code works.
I didn’t think that when you add an item into a list, that it also carried over the row or item from whence it came
@kartik14’s suggestion is good. @qaburns014w, there are various ways of doing this. Another efficient/effective way to do this will be to use an auto incrementing number. or row _key
when you pull data from your table, put the items from column ‘_key’ into 1 list. put the items from your desired column in another. When you click on an item, the index will correspond with the key from the same row in the _key list you just made.
Now, get column key without filtering, and save to alist. now, in this liist, find the first occurence of the _key from the step above. these blocks would be your row number.
because if column key is always being incremented, it never duplicates. therefore it may look like this
row, key, animal, date born, name
1, 23, cat, 3/14/15, jon
2, 24, dog, 3/15/17, jake
3, 33, cat, 3/15/17, jon
4, 35, horse, 3/18/17, noName
assume this is a subset of a larger set of data
key list: 1: 23, 2: 24, 3: 33, 4: 35
name list: 1: Jon, 2: jake, 3: Jon, 4: noName
this way, if you click on the first Jon, you would only get info from that row. then, if you look up the corresponding key to the name, you would get the row number
On screen load
get column "Keys"
set var.AllPossibleKeys = [green data event block]
when user click.ListItem
set var.KeyToMatch = in list 'key list' get # [index from listviewer event block]
set var.RowNum = in list [var.AllPossibleKeys] find first occurrence of [var.KeytoMatch]