I have a custom Doctype called Student, and one of its fields is department.
I want the List View of this Doctype to be grouped by department, so that all records under the same department appear together.
I’ve checked List View settings and custom scripts, but I’m not sure what is the correct way to implement grouping in the List View of a custom Doctype.
I think using the term “Group By” might be adding some confusion. Group By is a database query function that generates aggregate results.
Although you wrote “Group By”, I think you want to “Sort By”. In list view you’ll see the sort by field defaults to “last modified“. You can change the sort by field to “Department”. The arrow next to the sort by will change ascending/descending.
You can also edit the docType field ‘department’ properties and enable ‘in standard filter’, ‘in list view’ if you’d like an easy way to filter by department in list view.
I don’t want ordering — the ordering is already there. In the picture, I clearly show that the data is grouped by state, and each state’s data appears under its corresponding state
Regardless if you truly want a “Group By” , list view does not provide group by.
The screenshot is of a third party system. If you want to add features to ERPNext, you can create custom apps to meet your needs.
While you are looking for a group by, you are also expecting the full list. You want a hybrid result (which includes the group by count(), and the full list of results, sorted in your prefererred order.
As you can see from my screenshot, using Group By summarizes or creates an agregate result. This is not what you want. You’re looking for the results of two queries (one group by, and one with full results).