How to add gantt chart in custom doctype

Hi:

get_events_method is the key … this method provides data to show in gantt or calendar view. If you don’t specify it, just can access to parent doctype fields, not child table fields.

So … you need to create a method and use it in _calendar.js file, to get the data from database and render it on view.

Something like this … (note that field names could be different).

@frappe.whitelist()
def get_events(

	return frappe.db.sql(
		"""select from time as start_date, to_time as end_date, title from`tabLabour Allocation Details' ,
		as_dict=True,
	)

Take a look here:

Hope this helps.

1 Like