Tables > Leftmost Cell > Pin Row


TLDR: The ability to, within a table’s developer view, pin a single row.

Ideally, this would be achieved in the same way you manually delete a row; by right-clicking the leftmost cell of a row. In this pop-up menu, there should be an option called ‘Pin Row’. If the row is already pinned, this option will say ‘Unpin Row’.

Now, with this feature implemented, every table has two row types, Pinned and Unpinned.
When a developer manually ticks one of the table’s column’s sorting arrows, the Anvil Editor will apply sorting to Pinned and Unpinned rows independently. Such that, the UI will show all Pinned rows first, and Unpinned rows second with each collection having been sorted based on the table’s columns’ sorting arrows.


When a table is sorted, two independently sorted collections are returned.

# In the Anvil Editor's Data Service table-view, reverse alphabetic sort... 
----------
| Pinned |
----------
C
B
A
------------
| Unpinned |
------------
Z
Y
X

# as opposed to...
---------------
| Normal Sort |
---------------
Z
Y
X
C
B
A

But Jacob, why?

Well, maybe I need to keep a single row at the very top of a given table (no matter how it’s being sorted or viewed). A single, manually-pinned row in the Users Table row for my app’s Admin User. Or maybe I want to have 10-12 rows that are more important than all others, always being seen next to each other (regardless of any patterns in their cell data). Multiple manually-pinned rows for important rows I need to search constantly.


Closely-Related Additional Features:

  • Right-clicking the (currently empty) leftmost column cell in the table column header will allow developer to toggle between showing Pinned or Unpinned row first or second, and vice verse. Remember, this is a top-level sorting that is independent of actual table sorting queries and searches. This cell is currently empty and does nothing. Perfect little feature to add there.

  • Allow client-side access to a data table (such as when being displayed within a Data Grid Component) to delineate between Pinned and Default rows. In other words, add 1-2 attributes to anvil’s built-in table structure that allows the developer to access/search just Pinned rows or the Unpinned (default) rows. The current method for using a table would not change. This isn’t a new table structure. It’s data adjacent to the table structure. Maybe just store two lists of row IDs for Pinned and Unpinned in a dictionary?

    # I don't know exactly how this would be used in code... I'm not an engineer.

      normal_return = app_tables.an_actual_table.search()
      all_pinned_rows = normal_return.pinned
      
      # or maybe this would be more logical for developers...
      
      pinned_rows = app_tables.any_table.search(pinned=True)
      unpinned_rows = app_tables.any_table.search(pinned=False)
  • Specifically when viewing a table client-side with a Data Grid, add a checkbox toggle in the Data Grid’s Component Properties menu that allows the developer to mirror the automagically mirror the table’s pinned/unpinned row groups and their toggled order. Create a built-in method (only for option “Form: Can search, edit, and delete”) that allows the client-side user to pin row; not only a developer.

I believe this should all be built-in to anvil’s data table service, so it’s more optimized and less prone to errors than custom built implementations. Nice little feature that might save someone a lot of time. Also adds a bit of flavor to anvil when compared to other platforms. This has been done already in a tutorial from one of the staff, but this is something that should be built-in.


To Anvil, with love.

1 Like