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

Column template as grouping

I know grouping of grid happens on the "field", but how can I group a column if I want it based on what the template shows?

For example:

<e-column field="relative.FirstName" headerText="Name" width="120" [template]="second">
<ng-template #second let-data>
<ng-container *ngFor="let relative of data.Relatives">
<ng-container *ngIf="relative.Type === 'Mother'">
{{ relative.FirstName }}
ng-container>
ng-container>
ng-template>
e-column>

I tried to do it on relative.Firstname, which of course does not work, but I don't know how to make it work.

This is the link to the stackblitz: https://stackblitz.com/edit/angular-rqwpom

So how can I make sure I can group on the firstname of the mothers?



3 Replies

JC Joseph Christ Nithin Issack Syncfusion Team March 30, 2023 08:05 AM UTC

Hi Marijke,


  Greetings from Syncfusion support.




By default, the grouping of the grid is performed based on the values in the datasource. It is not feasible to group using the template values as the grid will not know the custom values given in the templates.


Regards,

Joseph I.



MM Marijke Meersman March 30, 2023 12:08 PM UTC

I understand, but the value I want to group on, is a value that is present in the datasource, just a little deeper and something like a forloop or maybe a .find() or so is necessary to find it. But you can't use nothing of those things in field="" then?



JC Joseph Christ Nithin Issack Syncfusion Team April 10, 2023 07:36 PM UTC

Marijke,



By default, the grouping of the grid is performed based on the values in the datasource. Using the templates, you can provide any words or even a different component in the template so we are not able to recognize the string provided inside a template. Also, we can group the columns only based on the column field names and we cannot use any other fields that is no in the grids columns. Hence your requirement is not feasible to be achieved.


Loader.
Live Chat Icon For mobile
Up arrow icon