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, |
This page will automatically be redirected to the sign-in page in 10 seconds.