Just got this working in FB8, here is the code:
// http://fogbugz.stackexchange.com/questions/1046/is-there-a-way-to-bulk-collapse-all-of-the-cases-in-a-filter/1052#1052
if( window.location.href.indexOf("pg=pgList") > 0 || window.location.href.indexOf("pgx=LF") > 0 || $("#bugGrid" ) )
{
console.info( "Running" );
$("#listNav").prepend("<a href='javascript:void 0;' onclick='toggleAllHierarchies(); return false;'>Collapse/Expand child cases</a> | ");
}
function toggleAllHierarchies()
{
var rgTRs = $("#bugGrid tr");
for (ix = 0; ix < rgTRs.length; ix++)
{
var oRow = rgTRs[ix];
if ($("a.arrow", oRow).length > 0)
{
GridControl.toggleNode(oRow.uid);
}
}
}