Click here to Skip to main content
15,886,038 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am new to JqGrid, I am using GroupingView functionality of JqGrid. It shows Collapse/Expand button with each group & on click of it it hides/shows the grouped items inside it. I want to hide & disable the Collapse/Expand button. Please find the JsFiddle link - http://jsfiddle.net/564RP/25/
Posted

1 solution

In your code you are setting the group text as below :-

JavaScript
groupText : ['<input name="chkHideTest" type="checkbox" class="groupHeader" isHidden="1" />   {0}  '],


Two things i added here like below :-
1. Name to the checkbox element like name="chkHideTest" and
2. one custom attribute named 'isHidden' then set its value to 1 for which you want to make it hidden otherwise zero, by checking the data coming from database.

In actuall the expand button is rendered as below code :-

HTML
<table><tbody><tr><td style="padding-left:0px;" colspan="8"><span style="cursor:pointer;" class="ui-icon  tree-wrap-ltr ui-icon-circlesmall-minus" onclick="jQuery('#grid').jqGrid('groupingToggle','gridghead_0_0');return false;"></span><input name="chkHideTest" type="checkbox" isHidden="1" class="groupHeader" name="grpHeader">   test  </td></tr></tbody></table>


So the just before element for the group input checkbox is the expand button which you want to disable/invisible there.

So we need to add a new setting for the grid as below which will be fired just after the load completion of the jqGrid as mentioned below :-

JavaScript
loadComplete:function(){
        $.each($("input[name='chkHideTest']"), function(i, obj){
	        var isHidden= $(obj).attr('ishidden');            
            if(isHidden)
            {
                $(obj).prev().hide();
            }
        });
    },
}


So this will hide the specific expand button which you dont want to view or else you can disable it by modifying the code a bit.

Hope this will definitely of help to you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900