i need gantt view in my custom doc type.how to i do that
Hi @Mohamed2335,
We added the Gantt view in the project doctype.
That for, please apply the client script for the listview.
Please check the syntax.
frappe.views.calendar["Project"] = {
field_map: {
"start": "expected_start_date",
"end": "expected_end_date",
"id": "name",
"title": "project_name",
"allDay": "allDay",
"progress": "progress"
},
gantt: true,
filters: [
{
"fieldtype": "Link",
"fieldname": "name",
"options": "Project",
"label": __("Project")
}
],
get_events_method: "frappe.desk.calendar.get_events"
}
Output:
I hope this helps.
Thank You!
Thanks sir, i need gantt chart for find same project list how i add that,
its works buts so error how to clear
Because expected_start_date, expected_end_date, and project_name field is available or not, in the Labour allocation doctype.
Please check the field name and set it accordingly.
Thank You!
this is my page sir, i need employee and project detail in gantt view
this code is correct?
frappe.views.calendar[“Labour Allocation”] = {
field_map: {
“start”: “from_time”,
“end”: “to_time”,
“id”: “name”,
“title”: “project”,
“allDay”: “allDay”,
“progress”: “progress”
},
gantt: true,
filters: [
{
“fieldtype”: “table”,
“fieldname”: “project_details”,
“options”: “labour_allocation_details”,
“label”: __(“project details”)
}
],
get_events_method: “frappe.desk.calendar.get_events”
}
Hi @Mohamed2335,
Please try it.
frappe.views.calendar["Labour Allocation"] = {
field_map: {
"start": "start_date",
"end": "end_date",
"id": "name",
"title": "parent_project",
"allDay": "allDay",
"progress": "progress"
},
gantt: true,
get_events_method: "frappe.desk.calendar.get_events"
};
I haven’t too much idea about the Gantt chart.
Reference:
I hope this helps.
Thank You!
thank you
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.
sir, can i add in client script orr server script
No, not possible as far I know.