How to make a custom tree view
Hi Petar Thank you for a great tool!. I need to show a treeview for an existing collection, with attribute parentId pointing to parent _id. The collection consists of more than 1000 object up to a depth of 6-7 levels. The existing tree_view seems to be hardcoded as a directory/file viewer, with relations between objects being established during run-time use. The objecttree custom component used in kitchen-site shows a treeview of a nested collection based on field name.
What is the best way to create a component for my need? Should I write something bottom-up, or can I for example use a tree view component on atmosphere?
@chef9 best way is to create custom component. All you need is two files (html and js). Html contains template and .js contains template.events and template.helpers. Many kitchen examples use custom components, but see example-markdowned first - it is simplest and cleanly shows how to use it (and json is 26 loc).
Your component will be reusable (in the same app or in multiple apps) if you don't hard-code template name and colection names. For that purpose you can use special keywords like TEMPLATE_NAME , COLLECTION_NAME etc. which will be automatically replaced by generator.
Let me know if youhave more questions.
Btw, there is also possibility to create "plugin" - it's very similar to custom_componemt but it allows you to create additional .js file which will be executed by generator (node) while building the app and here you have possibility to add custom properties to your component and use them to build html & js.
Thank you for a quick answer. I`ll opt for a custom component then :)