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

Display column with template in a string

Hi,


In my project, I have a grid where I have columns with template in a string.

Some templates are very complex, with other components to call, ngbModule to use etc etc... So the templateCompiler isn't the best choice in my case.


So, I'm creating component on the fly when my grid is initialized. It works great, but there are some limits.


For example, when I sort the data, my components doesn't move.

Also, its not working with the virtual scrolling.


So, which the best way to display my custom template in my case? Recreate component each time I filtering/sorting/search? It can be possible, but not very optimal with hu


I simplified as much as possible in my stackblitz, with a little template. So I know it is possible to working well with templateCompiler, but like I say, I have template in my data very complex.


https://stackblitz.com/edit/angular-hzefve?file=src%2Fapp.component.html,src%2Fdata.ts,src%2Fapp.component.ts,package.json,src%2Fapp.component.css


Thanks for yout help


4 Replies

AU Aurelien February 13, 2023 08:01 AM UTC

Anyone has an idea?



RS Rajapandiyan Settu Syncfusion Team February 13, 2023 10:21 AM UTC

Hi Aurelien,

Thanks for contacting Syncfusion support.


In our Syncfusion grid control, we can add the template only as the native element by the ng-template tag. We can’t create and add a component in the template method of the grid component. We need to use only the ng-template element to utilize the template support. Please refer to the following documentation on how to add a template to the grid component in the angular platform.

https://ej2.syncfusion.com/angular/documentation/grid/columns/column-template/


Regards,
Rajapandiyan S



AU Aurelien February 13, 2023 10:26 AM UTC

Okay I read this, but how can I make this in my case ?



SK Sathish Kumar Rajendran Syncfusion Team February 28, 2023 01:33 PM UTC

Hi Aurelien,

 

Sorry for the delay in our response.


After validating the case with custom templates in our grid component, we found that we couldn't achieve this scenario in the current grid architecture and our template compilation. Unfortunately, we don't have an alternative solution to suggest for your specific case.


If you have any other concerns, please let us know.


Regards, 
Sathish Kumar R



Loader.
Up arrow icon