Stump the Panel » jQuery for Everyone

Web Part Column Headings

(13 posts)
  • Started 6 days ago by ihmunro
  • Latest reply from AutoSponge
  1. ihmunro
    Member

    Morning

    I knwo I can make column heading disappear, but is it possible to show them when you need them?

    For example, I have a web part shoiwing a list of grouped items with a count - of course it looks ugly. You would think that when everything was collasped that everythnig would disappear, but you see everything, plus it takes up space etc.

    It almosst needs to look like it does if you minimise a webpart, but I need to see the grouped data, but then only see the column headings and counted items when i expand the list.

    Any ideas

    Posted 6 days ago #
  2. Sounds like it may be possible with jQuery, going to move this over to those forums.

    Posted 6 days ago #
  3. If I understand you, you want the top column headers in a grouped list view to remain hidden until one of the groups expands.

    If that's correct, do you need this on a single page or do you want to change the way the control works for EVERY list view?

    Posted 6 days ago #
  4. ihmunro
    Member

    Hi Paul

    I just to do this on a single page.

    Iain

    Posted 6 days ago #
  5. ok cool,

    Start with finding the header row: $("tr.ms-viewheadertr")

    and hide it: $("tr.ms-viewheadertr").hide();

    The rest of this comes from my article:
    http://www.endusersharepoint.com/?p=1489

    <script type="text/javascript">
     (function(){
    	var weave = function(source, method, advice){
    		var old = source[method];
    		var aspect = function() {
    			old.apply(this, arguments);
    			return advice.value.apply(this, [arguments]);
    		};
    		source[method] = aspect;
    		return aspect;
    	};
    	jQuery.aop = {
    		after : function(pointcut, advice){
    			var source = (typeof(pointcut.target.prototype) != 'undefined') ? pointcut.target.prototype : pointcut.target;
    			return weave(source, pointcut.method, { value: advice });
    		}
    	};
    })();
    $(function(){ //call a custom function after ExpGroupRenderData using the original arguments
    	$("tr.ms-viewheadertr").hide(); //start hidden
    
    	$.aop.after({target:window,method:"ExpGroupRenderData"}, function(args){
    		if (args[2]=='true'){$("tr.ms-viewheadertr").show();}
    	});
    });
    </script>
    Posted 6 days ago #
  6. ihmunro
    Member

    Hi Paul

    The $("tr.ms-viewheadertr").hide(); argument I have never used before - not sure where to start. If I want to hide i would normally do

    <Style>
    .ms-viewheadertr {display:none};
    </Style>

    Which obviously does not work with your jquuery statement.

    On the page, it is listed as <TR class="ms-viewheadertr"

    I am at a loss as to what I am supposed to do with $("tr.ms-viewheadertr").hide(); or where tp put it.

    Iain

    Posted 6 days ago #
  7. It's already in the script provided where it says //start hidden.

    Posted 5 days ago #
  8. ihmunro
    Member

    Thanks Paul

    YOur line that says

    Start with finding the header row: $("tr.ms-viewheadertr")

    I thought i am supposed to look for something.

    Are you saying just to add the script to a CEWP below the CEWP List?

    Iain

    Posted 5 days ago #
  9. The script above will work no matter where you put it. It has two chunks: 1) a module defining $.aop, 2) a section that will run when the document is ready.

    When the document is read, the script will add an action to the built-in ExpGroupRenderData function (what makes SP render new HTML when a group expands). This ensures that ExpGroupRenderData has loaded.

    This may not work with a DVWP or picture library (since they don't use ExpGroupRenderData, all data is already rendered it's just collapsed).

    Posted 5 days ago #
  10. ihmunro
    Member

    Hi Paul

    Just to let you know, I cannot get it to work.

    Iain

    Posted 4 days ago #
  11. I assume you already have jQuery on the page?

    Posted 4 days ago #
  12. ihmunro
    Member

    Hi Paul

    Yes I have jquery on the page. I tried moving the web parts around, it definately needs to be below the list. It is hiding the column headings, but even when they are expanded which is when I need to see them.

    Posted 3 days ago #
  13. What type of list is it? Some of the list types (DVWP and Picture library for sure) preload the content so this will not trigger the .show().

    Posted 2 days ago #

RSS feed for this topic

Reply

You must log in to post.