SharePoint doesn't has the ability to expand/collapse all groups in grouped list views. However, with jQuery we can bring Expand All-Collapse All buttons in SharePoint 2013 grouped list views. Just edit the grouped view page (Site Actions Gear >> Edit Page), add a "Script Editor" Web part and then place the below code in it.
jQuery for Expand-Collapse all items in grouped views in SharePoint 2013:
Thanks to: https://www.nothingbutsharepoint.com/sites/eusp/pages/jquery-for-everyone-expandcollapse-all-groups.aspx for the idea!
jQuery for Expand-Collapse all items in grouped views in SharePoint 2013:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.min.js"></script>and here is the result:
<script type="text/javascript">
function expandAll() {
$("img.ms-commentexpand-icon").click();
}
function collapseAll() {
$("img.ms-commentcollapse-icon").click();
}
var expandButton = "<a href='#' onClick="
+'"' + "this.href='javascript:expandAll()'"
+ '"> <img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/collapseplus.gif"></a>';
var collapseButton = "<a href='#' onClick="
+'"' + "this.href='javascript:collapseAll()'"
+ '"> <img title="expand all groups" style="border:none;" alt="collapse all" src="/_layouts/images/collapseminus.gif"></a>';
$(document).ready(function () {
$(".ms-pivotControl-container").append(expandButton).append(collapseButton);
});
</script>
Thanks to: https://www.nothingbutsharepoint.com/sites/eusp/pages/jquery-for-everyone-expandcollapse-all-groups.aspx for the idea!