# grid-column-template

> Data grid with a column template that renders each customer as an avatar with initials, a tinted color, and a delivery status badge.

**Framework:** angular  **Component:** Grid  **Variant:** column-template

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/angular/grid-column-template.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-angular-grids
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/grid-column-template/grid.component.html

```html
<div style="margin: 50px 90px">
  <ejs-grid [dataSource]='data' height='440' [rowHeight]='64' [allowPaging]='true' [pageSettings]='pageSettings' gridLines='Horizontal'>
    <e-columns>
      <e-column field='OrderID' headerText='Order' width='110' isPrimaryKey='true'>
        <ng-template #template let-data>
          <span style="font-family:monospace;font-size:12px;background:#f1f5f9;color:#334155;padding:4px 8px;border-radius:6px">#{{ data.OrderID }}</span>
        </ng-template>
      </e-column>
      <e-column field='ShipName' headerText='Ship To' width='240'>
        <ng-template #template let-data>
          <div style="display:flex;align-items:center;gap:12px">
            <span [style.background]="color(data.CustomerID)" style="width:38px;height:38px;border-radius:12px;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:13px">{{ initials(data.ShipName) }}</span>
            <div style="display:flex;flex-direction:column;justify-content:center">
              <span style="display:block;font-weight:600;color:#0f172a;line-height:20px">{{ data.ShipName }}</span>
              <span style="display:block;font-size:12px;color:#94a3b8;line-height:16px">{{ data.CustomerID }}</span>
            </div>
          </div>
        </ng-template>
      </e-column>
      <e-column field='ShipCity' headerText='Destination' width='150'>
        <ng-template #template let-data>
          <div style="display:flex;flex-direction:column;justify-content:center">
            <span style="display:block;color:#0f172a;line-height:20px">{{ data.ShipCity }}</span>
            <span style="display:block;font-size:12px;color:#94a3b8;line-height:16px">{{ data.ShipCountry }}</span>
          </div>
        </ng-template>
      </e-column>
      <e-column headerText='Status' width='150'>
        <ng-template #template let-data>
          <span [style.background]="status(data).bg" [style.color]="status(data).color" style="border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600">{{ status(data).label }} · {{ days(data) }}d</span>
        </ng-template>
      </e-column>
      <e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></e-column>
    </e-columns>
  </ejs-grid>
</div>
```

### src/components/grid-column-template/grid.component.ts

```typescript
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GridModule, PageService } from '@syncfusion/ej2-angular-grids';
import { orderData } from '../datasource/grid-data';

@Component({
  selector: 'app-grid-column-template',
  standalone: true,
  imports: [CommonModule, GridModule],
  providers: [PageService],
  templateUrl: './grid.component.html'
})
export class ColumnTemplateComponent {
  public data: Object[] = orderData;
  public pageSettings = { pageSize: 8 };
  private palette = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ec4899', '#8b5cf6'];

  public color(text: string): string {
    return this.palette[[...text].reduce((s, c) => s + c.charCodeAt(0), 0) % this.palette.length];
  }
  public initials(name: string): string {
    return name.trim().split(/\s+/).map(p => p[0]).slice(0, 2).join('').toUpperCase();
  }
  public days(o: any): number {
    return Math.max(0, Math.round((new Date(o.ShippedDate).getTime() - new Date(o.OrderDate).getTime()) / 86400000));
  }
  public status(o: any): { label: string; color: string; bg: string } {
    const d = this.days(o);
    return d <= 5 ? { label: 'Fast', color: '#059669', bg: '#d1fae5' }
      : d <= 10 ? { label: 'On time', color: '#0369a1', bg: '#e0f2fe' }
      : { label: 'Delayed', color: '#b45309', bg: '#fef3c7' };
  }
}
```
