Here's what I did to fix it:
- Add a Content Editor Web Part to your page. Anywhere will do.
- In the 'Source Editor...' for that CEWP, paste in this code:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>
$(document).ready(function () {
$('iframe[title="Hidden frame to filter list"]').each(function() {
var tbl = ($.browser.msie) ? $(this).parent().parent().parent().parent() : $(this).next();
var rows = tbl.children('tbody').eq(0).children('tr');
var cols = rows.eq(0).children('th').length;
var filter_col = '';
for (var c=0;c<cols;c++) {
if (rows.eq(0).children('th').eq(c).html().match('/_layouts/images/filter.gif')) {
filter_col = c;
}
}
if (filter_col > -1) {
for (var r=0;r<rows.length;r++) {
rows.eq(r).children('th, td').eq(filter_col).css('display','none');
}
}
});
});
</script> - The code works by detecting the little filter icon and hiding that column from the list.
- Yay jQuery!
Enjoy!


5 comments:
What if you have multiple web parts on the page? I added your code to a page and it only worked on the first web part that it found. The second one still showed the filter column.
It is interesting that they both have the same Title. I expected .each() to iterate through all iFrames on the page, but it seems to just find the first one on the page and does not move to the next web part. Odd.
Excellent work...This is exactly what I needed.
This is perfect. I have been needing something like this for a long time. I uploaded the jquery file to a SharePoint document library so that I didn't get the IE message about an unsecure site reference and changed the code to reference the SharePoint document.
Thanks for this code, but like WCDulanyJr, I have multiple web parts which are filtered. What should I do to hide filtered columns in all web parts ?
Thx
In fact this code is not working when there is a group by. Do you know how to improve here ?
Post a Comment