Can i update data view from list view to tree view

Dear Forestadmin Support Team,

Can i customize to update my self view of datatable from list view to tree view, pls see image below:

Thanks & Regards!
Hung Chu

Hi @chumanhhung235,

You are looking for prefixing Category names with spaces.
The number of spaces should match the number of nested levels, having a Parent Category field which is the parent.

This does not come out-of-the-box.

One idea (maybe not the best!) would be to add an integer field Level related to the nested level.
Then you can create a smart field that translates the nested level into a number of spaces to put as the Category prefix.
The problem is to maintain the Level field.
Depending on the update you plan to make to the tree, you can either:

  • Programmatically update all the children levels when an update is made
  • Or create a view which produces the Level field.

Whatever the solution you prefer, recursive queries will help you to evaluate the value of Level

This is just draft ideas, and it should be designed carefully.

Thank @Sliman_Medini, they’re good ideas.

How to translate number of spaces which defined in integer field Level?

This is a javascript question,
maybe by creating an array whose size is Level and to join it by spaces?

@Sliman_Medini: can i update (customize with javascript) with Community Package only?

At a first sight, you need to create:

A smart field CategoryWithIndentation with its getter and setter.
A sequelize save hook to update the field when ParentCategory changes.

This is all doable yes (this is idea of solution, I think there is others)

thank @Sliman_Medini so much, i will implement it with your solution.

1 Like