-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ag-grid): init column search table with AG-Grid
- Loading branch information
1 parent
a784e9a
commit d750d6e
Showing
6 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model'; | ||
// Theme | ||
import { ColDef, ModuleRegistry, GridReadyEvent } from '@ag-grid-community/core'; | ||
import { AgGridReact } from '@ag-grid-community/react'; | ||
// React Grid Logic | ||
import 'ag-grid-community/styles/ag-grid.css'; | ||
// Core CSS | ||
import 'ag-grid-community/styles/ag-theme-quartz.css'; | ||
import React, { useCallback, useState } from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
|
||
ModuleRegistry.registerModules([ClientSideRowModelModule]); | ||
|
||
// Row Data Interface | ||
interface IRow { | ||
make: string; | ||
model: string; | ||
price: number; | ||
} | ||
|
||
// Create new GridExample component | ||
const AgGridColumnSearch = () => { | ||
// Row Data: The data to be displayed. | ||
const [rowData, setRowData] = useState<IRow[]>([ | ||
{ make: 'Tesla', model: 'Model Y', price: 64950 }, | ||
{ make: 'Ford', model: 'F-Series', price: 33850 }, | ||
{ make: 'Toyota', model: 'Corolla', price: 29600 }, | ||
{ make: 'Mercedes', model: 'EQA', price: 48890 }, | ||
{ make: 'Fiat', model: '500', price: 15774 }, | ||
{ make: 'Nissan', model: 'Juke', price: 20675 }, | ||
]); | ||
|
||
// Column Definitions: Defines & controls grid columns. | ||
const [colDefs, setColDefs] = useState<ColDef<IRow>[]>([ | ||
{ field: 'make' }, | ||
{ field: 'model' }, | ||
{ field: 'price' }, | ||
]); | ||
|
||
const defaultColDef: ColDef = { | ||
flex: 1, | ||
}; | ||
|
||
const onGridReady = useCallback((params: GridReadyEvent) => { | ||
fetch('https://www.ag-grid.com/example-assets/row-data.json') | ||
.then((resp) => resp.json()) | ||
.then((data: IRow[]) => setRowData(data)); | ||
}, []); | ||
|
||
// Container: Defines the grid's theme & dimensions. | ||
return ( | ||
<div className={'ag-theme-quartz-dark'} style={{ width: '100%', height: '100%' }}> | ||
<AgGridReact | ||
rowData={rowData} | ||
columnDefs={colDefs} | ||
defaultColDef={defaultColDef} | ||
onGridReady={onGridReady} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
// Render GridExample | ||
const root = createRoot(document.getElementById('root')!); | ||
root.render(<AgGridColumnSearch />); | ||
|
||
export default AgGridColumnSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import AgGridColumnSearch from '../components/AgGrid/AgGridColumnSearch'; | ||
|
||
const AgGridPage = () => { | ||
return <AgGridColumnSearch />; | ||
}; | ||
|
||
export default AgGridPage; |