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

How do I Hide the PrimaryKey column and specify template

I am using Javascript with webapi. the webapi is not that important here. its the Javascript, 
How do i hide the primary key column ? In another scenario, I want to specify the tem[plate for each row to use, how can i do that?

Thanks


3 Replies

PS Pavithra Subramaniyam Syncfusion Team February 11, 2019 08:58 AM UTC

Hi Samuel, 
 
Thanks for contacting Syncfusion support.  
 
Query #1: How do i hide the primary key column ? 
 
You can hide any column by disabling the “column.visible” property. Please refer to the below code example and Documentation link. 
 
[index.cshtml]  
      var grid = new ej.grids.Grid({ 
        dataSource: data, 
        allowPaging: true, 
        columns: [ 
            { field: 'OrderID', headerText: 'ID', visible:false, textAlign: 'Right', width: 120, isPrimaryKey: true }, 
            { field: 'CustomerID', headerText: 'Custome ID', textAlign: 'Right', width: 120 }, 
            { field: 'EmployeeID', headerText: 'Employee ID', textAlign: 'Right' } 
        ] 
    }); 
 
    grid.appendTo('#Grid'); 
 
 
Query #2: In another scenario, I want to specify the template for each row to use, how can i do that? 
 
You can achieve your requirement by using the “column.template” which is used to render custom elements in grid cells of each row. Please refer to the below Documentation link and demo link for more information. 
 
                              https://ej2.syncfusion.com/javascript/documentation/grid/columns/#column-template  
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 



SA Samuel February 11, 2019 09:14 AM UTC

Thank you so much, it worked as i integrated in your sample perfectly!


TS Thavasianand Sankaranarayanan Syncfusion Team February 12, 2019 04:04 AM UTC

Hi Samuel, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.

Loader.
Live Chat Icon For mobile
Up arrow icon