We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to show or hide columns in TreeGrid at runtime

Platform: JavaScript |
Control: ejTreeGrid |
Published Date: July 27, 2016 |
Last Revised Date: May 29, 2019

It is possible to show or hide columns dynamically in TreeGrid using hideColumn and showColumn public methods. We need to pass the column header text as the method parameter.

 

The below code example explains about how to hide and show columns in TreeGrid

<div id="TreeGridContainer" style="height:400px;width:100%"></div>
<button onclick="hide()" style="margin-top:10px">Hide column</button>
<button onclick="show()" style="margin-top:10px">Show column</button>
<script type="text/javascript">
$(function () {
            $("#TreeGridContainer").ejTreeGrid({
                      //
                dataSource: projectData,
                columns: [
     { field: "taskID", headerText: "Task Id", editType: "numericedit", width: "60" },
     { field: "taskName", headerText: "Task Name", editType: "stringedit" },
     { field: "startDate", headerText: "Start Date", editType: "datepicker" },
     { field: "endDate", headerText: "End Date", editType: "datepicker",visible:false},
     { field: "duration", headerText: "Duration", editType: "numericedit" },
     { field: "progress", headerText: "Progress", editType: "numericedit" }
                ]          
            })
        }); 
        function hide() {
            var treeObj = $("#TreeGridContainer").data("ejTreeGrid");
            //To Hide the Particular column
            treeObj.hideColumn("Task Id");
        }
        function show() {
            var treeObj = $("#TreeGridContainer").data("ejTreeGrid");
            //To show the Particular column
            treeObj.showColumn("End Date");
        }
</script>

A sample to hide/show columns in TreeGrid is available in the following link,

Sample

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon