|
1 | 1 |
|
2 | 2 | import { useState } from 'react'; |
3 | | -import { DataGrid, GridToolbar, GridColDef, GridFilterModel, GridTooltip, exportToCsv, exportToExcel, exportToJson, printGrid } from '@opencorestack/opengridx'; |
| 3 | +import { DataGrid, GridToolbar, GridColDef, GridRowModel, GridFilterModel, GridTooltip, exportToCsv, exportToExcel, exportToJson, printGrid } from '@opencorestack/opengridx'; |
4 | 4 | import { DocsLayout } from '../../components/DocsLayout'; |
5 | 5 | import './AdvancedFilteringDemo.css'; |
6 | 6 |
|
7 | 7 | import sourceCode from './AdvancedFilteringDemo.tsx?raw'; |
8 | 8 |
|
| 9 | +interface Employee extends GridRowModel { |
| 10 | + id: number; |
| 11 | + firstName: string; |
| 12 | + lastName: string; |
| 13 | + age: number; |
| 14 | + department: string; |
| 15 | + salary: number; |
| 16 | + active: boolean; |
| 17 | +} |
| 18 | + |
9 | 19 | interface ExportToolbarProps { |
10 | 20 | apiRef?: any; |
11 | | - fallbackRows: any[]; |
12 | | - fallbackColumns: GridColDef[]; |
| 21 | + fallbackRows: Employee[]; |
| 22 | + fallbackColumns: GridColDef<Employee>[]; |
13 | 23 | } |
14 | 24 |
|
15 | 25 | function ExportToolbar({ apiRef, fallbackRows, fallbackColumns }: ExportToolbarProps) { |
@@ -113,7 +123,7 @@ function ExportToolbar({ apiRef, fallbackRows, fallbackColumns }: ExportToolbarP |
113 | 123 | ); |
114 | 124 | } |
115 | 125 |
|
116 | | -const rows = [ |
| 126 | +const rows: Employee[] = [ |
117 | 127 | { id: 1, firstName: 'Jon', lastName: 'Snow', age: 35, department: 'Engineering', salary: 95000, active: true }, |
118 | 128 | { id: 2, firstName: 'Cersei', lastName: 'Lannister', age: 42, department: 'Management', salary: 140000, active: false }, |
119 | 129 | { id: 3, firstName: 'Jaime', lastName: 'Lannister', age: 45, department: 'Security', salary: 88000, active: true }, |
@@ -141,9 +151,9 @@ const rows = [ |
141 | 151 | { id: 25, firstName: 'Tormund', lastName: 'Giantsbane', age: 38, department: 'Security', salary: 72000, active: true }, |
142 | 152 | ]; |
143 | 153 |
|
144 | | -const columns: GridColDef[] = [ |
| 154 | +const columns: GridColDef<Employee>[] = [ |
145 | 155 | { field: 'id', headerName: 'ID', width: 70, type: 'number' }, |
146 | | - { field: 'firstName', headerName: 'First Name', width: 140 }, |
| 156 | + { field: 'firstName', headerName: 'First Name', flex: 1, width: 100 }, |
147 | 157 | { field: 'lastName', headerName: 'Last Name', width: 150 }, |
148 | 158 | { field: 'age', headerName: 'Age', width: 90, type: 'number' }, |
149 | 159 | { field: 'department', headerName: 'Department', width: 150 }, |
|
0 commit comments