Tree View for records Based on Field

Lets say you have a Products model. Within each Product record, there is a field called Category.

So, I want to set this model to have “Tree View Based on Field” and set the Field to the Category field, resulting in a presentation of records like:

  • Category
    • Product
    • Product
  • Category
    • Product

In other words, a Tree View that isn’t arbitrarily dragged and dropped. Rather, the tree structure reflects record data. The way to move things between Tree nodes is just to edit the field that is tied to the Tree.

That field could be text, or it could be a Link field to a Category model, or anything else; but whatever it is, we can stringify it. (If it’s a link to another model, we take the string already being used to name that record). The stringified field is simply used to create the Tree headings in the record viewer.

Edge cases:

  • What if you attach the Tree structure to a multiple-link field? Then, that record will appear under multiple headings. Or, just the first.

For bonus points:

  • If you attach the Tree structure to a Link field, then when you click that heading in the Tree you can actually edit the linked record in its different model - in place.
  • If you drag and drop records to a different heading, you effectively change the Tree field’s value.
  • Multi-level Trees Based on Fields. e.g. I set the Products model to Tree Based on Fields. Then add Level 1 = the Section field, and Level 2 = the Category field.