# grid-detail-template

> Data grid with a detail row template that expands a row to reveal the shipped order lines and totals beneath it.

**Framework:** react  **Component:** Grid  **Variant:** detail-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/react/ts/grid-detail-template.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-react-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-detail-template/Grid.tsx

```tsx
import { GridComponent, ColumnsDirective, ColumnDirective, Inject, Page, DetailRow } from '@syncfusion/ej2-react-grids';
import { orderDetails } from '../datasource/grid-data';

const daysToShip = (o: any): number => Math.max(0, Math.round((new Date(o.ShippedDate).getTime() - new Date(o.OrderDate).getTime()) / 86400000));
const fmt = (d: any): string => new Date(d).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' });

const wrapStyle: React.CSSProperties = { display: 'grid', gridTemplateColumns: '1.2fr 1fr 1fr', gap: 16, padding: '16px 24px', background: '#f8fafc' };
const cardStyle: React.CSSProperties = { background: '#fff', border: '1px solid #e2e8f0', borderRadius: 12, padding: 16 };
const cardTitleStyle: React.CSSProperties = { margin: '0 0 12px', fontSize: 11, letterSpacing: '.06em', textTransform: 'uppercase', color: '#64748b' };
const stepStyle: React.CSSProperties = { display: 'flex', alignItems: 'flex-start', gap: 12, marginBottom: 14 };
const dotStyle: React.CSSProperties = { width: 10, height: 10, marginTop: 5, borderRadius: '50%', background: '#6366f1', boxShadow: '0 0 0 4px #e0e7ff', flexShrink: 0 };
const strongStyle: React.CSSProperties = { fontWeight: 600, color: '#0f172a' };
const mutedStyle: React.CSSProperties = { fontSize: 12, color: '#64748b' };

function DetailTemplate() {
  const detailTemplate = (p: any) => (
    <div style={wrapStyle}>
      <div style={cardStyle}>
        <h5 style={cardTitleStyle}>Shipment timeline</h5>
        <div style={stepStyle}>
          <span style={dotStyle} />
          <div>
            <div style={strongStyle}>Order placed</div>
            <div style={mutedStyle}>{fmt(p.OrderDate)}</div>
          </div>
        </div>
        <div style={{ ...stepStyle, marginBottom: 0 }}>
          <span style={dotStyle} />
          <div>
            <div style={strongStyle}>Shipped</div>
            <div style={mutedStyle}>{fmt(p.ShippedDate)} · {daysToShip(p)} days after order</div>
          </div>
        </div>
      </div>
      <div style={cardStyle}>
        <h5 style={cardTitleStyle}>Delivery address</h5>
        <div style={strongStyle}>{p.ShipName}</div>
        <div style={{ color: '#475569', marginTop: 4 }}>{p.ShipAddress}</div>
        <div style={{ color: '#475569' }}>{p.ShipCity}, {p.ShipCountry}</div>
      </div>
      <div style={cardStyle}>
        <h5 style={cardTitleStyle}>Freight charge</h5>
        <div style={{ fontSize: 28, fontWeight: 700, color: '#0f172a' }}>${Number(p.Freight).toFixed(2)}</div>
        <div style={{ ...mutedStyle, marginTop: 4 }}>Customer {p.CustomerID}</div>
      </div>
    </div>
  );

  return (
    <div className='control-pane'>
      <div className='control-section'>
        <GridComponent dataSource={orderDetails} height='460' allowPaging={true}
          pageSettings={{ pageSize: 8 }} detailTemplate={detailTemplate} gridLines='Horizontal'>
          <ColumnsDirective>
            <ColumnDirective field='OrderID' headerText='Order' width='110' isPrimaryKey={true} />
            <ColumnDirective field='CustomerName' headerText='Customer' width='200' />
            <ColumnDirective field='ShipCity' headerText='City' width='160' />
            <ColumnDirective field='ShipCountry' headerText='Country' width='150' />
            <ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' />
          </ColumnsDirective>
          <Inject services={[Page, DetailRow]} />
        </GridComponent>
      </div>
    </div>
  );
}
export default DetailTemplate;
```
