Customize DocType: create Tree View

Hey,

i want to add a new view (a tree view) for my project templates to get a better overview).
But i can’t see a flag or anything else in the customize form.

Is it possible to add tree view to any doctype? in my example for project templates?

regards and thx, daniel

@Daniel_Grammer doctypes are just a list of some data . how are you gonna display them as a tree ?

In your doctype settings page there should be a is tree checkbox. If you check that, it should automatically create a tree view for your doctype and you can see the view by going to your doctype’s list view and changing the view from the dropdown (tree view would be available then).

Hey, thanks for your response.

Yes I see it, but if i check on the “Is Tree” Checkbox, the save button gets hidden.
Is it possible, that treeview is’nt allowed for “Project Template” - Doctype? (i mean the default erpnext “project template” doctype)

I was able to edit the “Project Template” DocType, marking the “Is Tree” checkbox, and saved successfully.

This was in an environment in development mode, and I was logged in as Administrator.

:man_shrugging:

Hey, thanks i try them in development mode, it works, but if i try to add a new tree child nothing happens. Also when i try to add a new group they ask for all mandatory fields.

Do you have an idea about this?

Hmm like @brian_pond said it works as Admin in Dev mode, I’ll have to look into exactly why it happens only then (imo it should be made accessible for the system managers).

Hmm not sure but i’ll try my best to explain.

So when you check the istree checkbox, you’ll see that some additional fields have been added to your doctype. 2 of the them are is group and parent something. So when creating a new doc, if you’ve checked is group, you’re saying that, that doc can have child docs linked to it (in a tree fashion) and when you want to link a doc to that is group checked doc, you just select that as the child doc’s parent in the parent something field.
Also note that the first is group doc you’ll create will be your root node of the tree.

What you’re doing is tricky, @Daniel_Grammer. You’re trying to take an existing DocType, with existing data, and transform into a Tree. Possible? Yes. However, you won’t find any instructions or documentation on how to accomplish this. It’s not something typically done.

I do agree with @ritwik. Part of using the “tree” feature is defining the parent-child relationship between the rows.

To learn more, I recommend you try this. Create a brand-new DocType. In the screenshot below, I added a single DocField to mine: Description. When you save as a Tree, notice how 5 additional DocFields are automatically created for you?

Those fields are what make the Tree “work”. When you Create/Update/Delete documents using the web page, those fields are automatically handled for you.

However…you’re working with a pre-existing DocType: 'Project Templates'. Because you’re applying the Tree attribute after-the-fact? Most of these fields won’t have the correct values. So you’ll have to edit them manually. Either with a data import, or using a SQL client. Defining which row is the top-level root of the tree. Which rows relate to other rows. And more.

For an example of how this works normally, check out the 'Warehouse' DocType. Create some Warehouses, some groups, and build a structure. Then take a look at the underlying SQL data. That should explain how the Tree works. Then you could go back, and apply some updates to Project Templates.

1 Like