You have several approaches available.
The @ operator can be used to index a list, dictionary, or table by a list of indices or keys. For example:
items.value
# +--------------+-------+--------+
# | fruit | price | amount |
# +--------------+-------+--------+
# | "apple" | 1 | 1 |
# | "cherry" | 0.35 | 15 |
# | "banana" | 0.75 | 2 |
# | "durian" | 2.99 | 5 |
# | "elderberry" | 0.92 | 1 |
# +--------------+-------+--------+
items.value.fruit @ 0,2,3
# ("apple","banana","durian")
Indexing a table in this way gives us a list of rows (each a dictionary), but we can glue those back together with the "table" operator:
items.value @ 0,2,3
# ({"fruit":"apple","price":1,"amount":1},{"fruit":"banana","price":0.75,"amount":2},{"fruit":"durian","price":2.99,"amount":5})
table items.value @ 0,2,3
# +----------+-------+--------+
# | fruit | price | amount |
# +----------+-------+--------+
# | "apple" | 1 | 1 |
# | "banana" | 0.75 | 2 |
# | "durian" | 2.99 | 5 |
# +----------+-------+--------+
To clarify my earlier examples, in most applications the "in" operator attempts to check whether an item on the left (or each item in a list on the left) appears within a list on the right:
3 in 2,4,5 # 0 5 in 2,4,5 # 1 (3,5) in 2,4,5 # (0,1)
Within a query, you could do something roughly equivalent to our first example by referencing the implicit "magic column" named "index":
select where index in 0,2,3 from items.value # +----------+-------+--------+ # | fruit | price | amount | # +----------+-------+--------+ # | "apple" | 1 | 1 | # | "banana" | 0.75 | 2 | # | "durian" | 2.99 | 5 | # +----------+-------+--------+
If your desired indices are stored in a table, you'll need to pluck out a column of that table before you can compare it to another column with "in" or index with "@":
invgrid.value # +-----------+ # | itemIndex | # +-----------+ # | 0 | # | 2 | # | 3 | # +-----------+ invgrid.value.itemIndex # (0,2,3) table items.value @ invgrid.value.itemIndex # +----------+-------+--------+ # | fruit | price | amount | # +----------+-------+--------+ # | "apple" | 1 | 1 | # | "banana" | 0.75 | 2 | # | "durian" | 2.99 | 5 | # +----------+-------+--------+ select where index in invgrid.value.itemIndex from items.value # +----------+-------+--------+ # | fruit | price | amount | # +----------+-------+--------+ # | "apple" | 1 | 1 | # | "banana" | 0.75 | 2 | # | "durian" | 2.99 | 5 | # +----------+-------+--------+
You might consider keeping track of inventory items based on their names, or some other semantically meaningful "id" or key column, rather than by index; it could be more human-readable, and if you make any mistakes writing your queries it may be more obvious where something has gone wrong.
I would also like to note that grids aren't the only way to store collections of data within Decker, and may not always be the simplest choice. For example, you could also store a list of indices in a field widget via its .data attribute. Say we have a field named "myList":
myList.data:11,22,33
The field will visually show the data as "[11,22,33]". If we read myList.data we can reconstitute the list:
myList.data # (11,22,33)
Does that help?