ERPNext Conference 2019* Blog

How to Add Department Name in Employee Tree


I want to show department Name in Employee tree currently it show Employee name and Employee ID


It won’t be possible out of the box.

Customization will be needed either on the frappe tree.js and employee query etc OR you can do a little javascript tweak in the employee_tree.js.
Here’s a sample tweak

	onrender(node) {
		let page = $(document);
		if(!node.is_root) {
			frappe.db.get_value("Employee",, "department")
				.then((r) => {
						let x = page.find(`span[data-label="${}"] .tree-label span.text-muted`);
						x.text(` ${ x.text() } ( ${r.message.department} )`);

Create Tree View and a Tree Browser for any DocType

Thanks zarrar


Thanks for this topic, it helped us immensely with the new Animal Group DocType tree view for AgriNext! :muscle:t2: