ERPNext Conference 2019* ERPNext.com Blog

How to Add Department Name in Employee Tree


#1

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


#2

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", node.data.value, "department")
				.then((r) => {
					if(r.message.department){
						let x = page.find(`span[data-label="${node.data.value}"] .tree-label span.text-muted`);
						x.text(` ${ x.text() } ( ${r.message.department} )`);
					}
				})
		}
	}

Create Tree View and a Tree Browser for any DocType
#3

Thanks zarrar


#4

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