I want to create a tree table to display files using backbone.js + jQuery.
I’m having trouble with the layout. I currently have a View representing the entire table and another view representing a row.
The problem is, how do I take into account files in the folders (i.e. sub-rows in this case)? The data for files logically belongs in their folders, meaning that they would be data belonging to a row. How then do I get one row to create other rows that by html are not children, rather siblings?
the problem with a
tableis that it is flat data, not tree data.i’d find a way to modify my data to be shown, from a tree into a flat structure.
lets say your tree is a collection of folders, each with their collection of files and so on.
why not extract it to a json blob of all files (from all folders) with the folder attributes on the file model.
you can now perfectly loop trough your files creating new rows per file
depending on which attributes it have you can add different things in your view, like collspans or classes for special css styling.
another solution is to throw out the
tableidea, and usedivorulinstead,then you can work with your tree structure, a div as parent, with sub elements per file / subfolder.