Easy expand or collapse Sharepoint List in Group by view

When you group list items by some fields, by default Sharepoint have the items collapsed. It’s quite annoying to have to manually expand each. There’s a way you could easily expand all list items or collapse in one click.

Simply add a Content Editor web part and put the following JavaScript in source. Place it above your list view and done.

<script type="text/javascript">
if(typeof jQuery=='undefined'){
 var jQPath = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3/'
 document.write('<script src="',jQPath,'jquery.min.js" type="text/javascript"><\/script>');
<script type="text/javascript">
 * Copyright (c) 2008 Paul Grenier (endusersharepoint.com)
 * Licensed under the MIT (MIT-LICENSE.txt)
function collapseGroups() {
function expandGroups() {
$(function() {
 var expandAll = "<a href='#' onClick="
  +'"><img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/collapseplus.gif"></a>';
 var collapseAll = "<a href='#' onClick="+'"'
  +'"><img title="collapse all groups" style="border:none;" alt="collapse all" src="/_layouts/images/collapseminus.gif"></a>';
 $("table.ms-menutoolbar td.ms-toolbar[width='99%']").append(expandAll).append(collapseAll);