How to use content projection to set dynamic e-columns

Hi,

I want to create a generic configurable component that contains only a "ejs-grid" but the "e-columns" should be provided from the outside when using it. Moreover I need to allow to provide "e-column"'s with template and others without template.

My intention is to have at the end something like this but I can't make it work:

. Generic component "my-generic-grid" html:

<ejs-grid [dataSource]='data'>
<ng-content>ng-content>
ejs-grid>

. Using this component from other one like this:

<my-generic-grid [config]="config">
<e-column field="user" headerText='User'>e-column>
<e-column headerText='Check'>
<ng-template #template let-data columnTemplate>
<input type="checkbox" checked>
ng-template>
e-column>
my-generic-grid>


Do you know if something like this is possible?

thanks



3 Replies

PS Pavithra Subramaniyam Syncfusion Team February 4, 2022 01:09 PM UTC

Hi Ezequiel, 

Thanks for contacting Syncfusion support. 

Currently we are validating the scenario “Content projection for Grid child directives” our side and we will update further details on Feb 08th, 2022. Until then we appreciate your patience. 

Regards, 
Pavithra S 



PS Pavithra Subramaniyam Syncfusion Team February 8, 2022 12:12 PM UTC

Hi Ezequiel,  

Sorry for the inconvenience.  

Since we are facing some complexities with the reported scenario validation, we will update further details on Feb 10th, 2022. Until then we appreciate your patience.  

Regards,  
Pavithra S 



PS Pavithra Subramaniyam Syncfusion Team February 11, 2022 12:41 PM UTC

Hi Ezequiel,   

Thanks for your patience. 

In our EJ2 Grid component the columns will be rendered if the grid component has the “e-columns” tag or setting the columns in a typescript way only as in the below sample. Otherwise, the Grid columns will be autogenerated from the available fields in the Grid data source. This is the default behavior of Grid component. So, we could not render the column inside the “ng-content”. Please refer to the below sample for more information. 


Regards, 
Pavithra S 


Loader.
Up arrow icon