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. Image for the cookie policy date
close icon

Hide Grid Header Row when the column uses a jsrender Template is not working

Hi Support:

I have a grid with only one column defined a template as:

<e-columns>
       <e-column template="#detailTemplate"></e-column>
</e-columns>

But the following code is ignored:

function onDatabound(args) {
          
            //hide Grid header
            this.getHeaderContent().addClass("e-hide");
}

There is no error, but the header does not get hidden.

Thanks in advanced

David



5 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 3, 2017 05:27 PM UTC

Hi customer, 

Thanks for contacting syncfusion support. 

You can hide the Header of the template column by using “data-bound” event of the Grid. In the below code example we have bound the “data-bound” event for the grid and from that we have remove the header element of grid using “getHeaderTable” method in grid.  
 
Please refer to the code example:- 
 
<ej-grid id="FlatGrid" allow-paging="true" data-bound="bound" datasource="ViewBag.DataSource"> 
     <e-columns> 
          <e-column field="OrderID" template="#detailTemplate" is-primary-key="true"></e-column> 
          <e-column field="EmployeeID"></e-column> 
          <e-column field="CustomerID"></e-column> 
          <e-column field="Freight"></e-column> 
      </e-columns> 
 </ej-grid> 
     <script> 
            function bound(args) { 
                this.getHeaderTable().remove(); 
 
            } 
     </script> 
 
 
Please get back to us if you need any further assistance. 

Regards, 

Farveen sulthana


DS dsapo July 5, 2017 08:38 PM UTC

Hi Farveen :

I tried your suggestion but it did not work.


To remove the header row I added the following css, but is not an elegant solution, so I prefer to make it to work with your approach:

 .e-headercell, .e-headercelldiv, .e-gridheader

    {

        height:0 !important;

        border:0 !important;

    }


My Grid definition is:

 <ej-grid id="grid1"

                                 action-begin="begin"

                                 allow-resize-to-fit="true"

                                 allow-paging="true"

                                 is-responsive="true"

                                 enable-row-hover="false"

                                 allow-selection="false"

                                 action-complete="onComplete" 

                                 data-bound="onDatabound"

                                 >

                           <e-datamanager url="/DataSource" adaptor="UrlAdaptor" />

                            <e-columns>

                                <e-column template="#detailTemplate"></e-column>

                            </e-columns>

                            <e-page-settings page-size="10"></e-page-settings>

                        </ej-grid>


What could be my issue.

Regards,

David





FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 6, 2017 03:52 PM UTC

Hi David, 

We are unable to reproduce your reported problem “Grid Header doesn’t get hide’ at your end. Could you please share us the following details to find the cause of the issue. 

1. Grid code example( share the code example of data-bound event ). 

2. Have you used any customized CSS for Grid. If so please share the code. 

3. Screenshot or Video if any script error occurs.  

The provided information will help us to analyze and provide you the solution as early as possible. 
 
Regards, 
 
Farveen sulthana T 




DS dsapo July 12, 2017 03:59 PM UTC

Thanks Farveen.

Now is working as expected.




FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 13, 2017 10:46 AM UTC

Hi David, 
  
Thanks for your update that your reported problem was resolved. 
  
Please get back to us if you need any further assistance. 
  
Regards, 
  
Farveen sulthana T 


Loader.
Live Chat Icon For mobile
Up arrow icon