Using checkboxes and javascript to hide columns in treegrid

Hi,

Is it possible to have checkboxes on the page using javascript ( not using postback) to hide entire columns in a tree grid ?

David

1 Reply

PE Punniyamoorthi Elangovan Syncfusion Team March 23, 2018 12:48 PM UTC

Hi David, 
Thank you for contacting Syncfusion support. 
We have analyzed your requirement and we can achieve this by using hideColumn and showColumn public methods. Please refer the below code snippet. 
<div id="checkBox"> 
       <input type="checkbox" style="height:20px;width:20px"  checked="checked" id="hideShow" /> <label>Hide/Show HEAD1 column</label> 
</div> 
 
<script type="text/javascript"> 
        $("#hideShow").click(function (e) { 
            e = e || window.event; 
             var targetEle = e.target, 
             treeObj = $("#TreeGrid").data("ejTreeGrid"), 
             checkStatus = $(targetEle).is(':checked'); 
             if (checkStatus == false) { 
                 treeObj.hideColumn("Head1"); //passing the header text to hide the column 
             } 
             else { 
                 treeObj.showColumn("Head1"); //passing the header text to show the column 
             } 
        }) 
          
</script> 
Please let us know whether you need to hide the entire columns in TreeGrid while checking and unchecking the checkbox. 
We have prepared the sample for hiding a specific column present in TreeGrid. Please find the sample link below 
Regards, 
Punniyamoorthi 


Loader.
Up arrow icon