-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffad394
commit ef0051b
Showing
3 changed files
with
66 additions
and
23 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,26 +1,57 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import React, { Component } from 'react'; | ||
import './App.scss'; | ||
import { AgGridReact } from 'ag-grid-react'; | ||
import 'ag-grid-enterprise'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
|
||
class App extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
columnDefs: [{ | ||
headerName: "Make", field: "make", rowGroup: true | ||
}, { | ||
headerName: "Price", field: "price" | ||
}], | ||
rowData: null, | ||
autoGroupColumnDef: { | ||
headerName: "Model", | ||
field: "model", | ||
cellRenderer: 'agGroupCellRenderer', | ||
cellRendererParams: { | ||
checkbox: true | ||
} | ||
} | ||
} | ||
} | ||
componentDidMount() { | ||
fetch('https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/sample-data/rowData.json') | ||
.then(result => result.json()) | ||
.then(rowData => this.setState({ rowData })) | ||
} | ||
|
||
onButtonClick = e => { | ||
const selectedNodes = this.gridApi.getSelectedNodes() | ||
const selectedData = selectedNodes.map(node => node.data) | ||
const selectedDataStringPresentation = selectedData.map(node => node.make + ' ' + node.model).join(', ') | ||
alert(`Selected nodes: ${selectedDataStringPresentation}`) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div style={{ height: '250px', width: '600px' }} className="ag-theme-alpine"> | ||
<button onClick={this.onButtonClick}>Get selected rows</button> | ||
<AgGridReact | ||
rowSelection="multiple" | ||
onGridReady={params => this.gridApi = params.api} | ||
columnDefs={this.state.columnDefs} | ||
groupSelectsChildren={true} | ||
autoGroupColumnDef={this.state.autoGroupColumnDef} | ||
rowData={this.state.rowData}> | ||
</AgGridReact> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
export default App; |
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,8 @@ | ||
@import "../node_modules/ag-grid-community/src/styles/ag-grid.scss"; | ||
@import "../node_modules/ag-grid-community/src/styles/ag-theme-alpine/sass/ag-theme-alpine-mixin.scss"; | ||
|
||
.ag-theme-alpine { | ||
@include ag-theme-alpine(( | ||
odd-row-background-color: #BFC8DC | ||
)); | ||
} |