How to hide column header of parent grid but not detail component?

Inside of a grid, I'm displaying a child treegrid using the grid's capability of displaying a custom component in its detail row, as illustrated here:

Everything works great. But I'm wanting to hide the column header area of the parent grid, while still displaying the column header of the child (detail) treegrids.

I know I can do this as a style:

        e-headercell, .e-headercelldiv, .e-gridheader {
            height: 0 !important;
            border: 0 !important;
        }

but the problem is, that hides the header of both the parent grid and the detail treegrids. Is there a way I can hide the header of just the parent grid?



3 Replies

PS Pavithra Subramaniyam Syncfusion Team May 20, 2020 09:40 AM UTC

Hi Phil, 
 
Greetings from Syncfusion support. 
 
You can achieve your requirement by adding a custom class for the header element inside the “created” event of Parent Grid. Please refer to the below code example and documentation link for more information. 
 
[index.cshtml] 
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" detailTemplate="#detailtemplate" created="created" 
  detailDataBound="detailDataBound"> 
  <e-grid-columns> 
    <e-grid-column field="FirstName" headerText="First Name" width="110"></e-grid-column> 
    <e-grid-column field="LastName" headerText="Last Name" width="110"></e-grid-column> 
  </e-grid-columns> 
</ejs-grid> 
 
<script> 
  function created(e) { 
    var gridObj = document.getElementById("Grid").ej2_instances[0]; 
    gridObj.getHeaderContent().classList.add("e-custom"); // Adding custom class for parent header element 
        } 
</script> 
 
<style> 
  .e-custom.e-gridheader { 
    // here you can add the custom styles 
} 
</style> 
 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S 



PS Phil Seeman May 20, 2020 01:36 PM UTC

That's perfect, thanks!


AG Ajith Govarthan Syncfusion Team May 21, 2020 03:34 PM UTC

Hi Phil, 

We are happy to hear that the provided solution has been working fine at your end. 

Please get back to us if you need further assistance. 

Regards, 
Ajith G. 


Loader.
Up arrow icon