locked
Expand empty subgroups and remove group header in grouped list view? RRS feed

  • Question

  • Expand empty subgroups and remove group header in grouped list view?

     

    This below code is working, but only problem is when i click group first click its not wrking but second click on words its working, plz giv me the exact solution.

    I am trying this way.

     

     

    <script type="text/javascript" src="../../Javascript/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	// Add onclick to the first grouping
    	$(".ms-listviewtable td.ms-gb").click(function(){
    		expandEmptyCategory();
    	});	
    	// Call function on load
    	isTbodyLoaded();	
    });
    
    var isloadedCheck = 0;
    // Looping function to call "expandEmptyCategory" when subgroups are loading - looping every 200ms for a maximum of 4 seconds
    function isTbodyLoaded(){
    	setTimeout(function(){
    		tbodyIsLoadedLength = $(".ms-listviewtable tbody[isLoaded='true']").length;
    		if(tbodyIsLoadedLength>0){
    			expandEmptyCategory();
    		}else{
    			isloadedCheck += 1;
    			if(isloadedCheck<=20){
    				isTbodyLoaded();
    			}
    		}
    	},200);
    }
    
    function expandEmptyCategory(){
    var NameGrouping2 = $(".ms-listviewtable td.ms-gb2:first a:eq(1)").text();
    	$(".ms-listviewtable td.ms-gb2").each(function(){	
    		var grNameRaw = $(this).text().replace(NameGrouping2+' :','');
    		grName = grNameRaw.substring(0,grNameRaw.indexOf('(')-1).replace(/\s|\xA0/g,'');
    		if(grName.length==0){
    		var parentTbody = $(this).parents('tbody:first');
    			if(parentTbody.css('display')!='none'){
    			var tIdRaw = parentTbody.attr('id');
    			var tId = tIdRaw.substring(4);
    			var tb = $("#tbod"+tId+"_");
    				if(tb.attr('isLoaded')){
    					if(tb.css('display')=='none'){
    						$(this).find('a:first').click();
    						$(this).parents('tbody:first').hide();
    					}else{
    						$(this).parents('tbody:first').hide();
    					}
    				}
    			}		
    		}	
    	});
    }
    </script>

     

    • Moved by Max Meng Thursday, January 12, 2012 6:11 AM Moving to a more appropriate forum (From:Office 2007 Planning and Deployment)
    Wednesday, January 11, 2012 7:23 AM

Answers

All replies