import ReactDOM from 'react-dom'; import React from 'react'; import {AgGridReact} from 'ag-grid-react'; import RefData from './RefData'; import RowDataFactory from './RowDataFactory'; import ColDefFactory from './ColDefFactory.jsx'; import './myApp.css'; // take this line out if you do not want to use ag-Grid-Enterprise import 'ag-grid-enterprise'; export default class MyApp extends React.Component { constructor() { super(); this.state = { quickFilterText: null, showGrid: true, showToolPanel: false, columnDefs: new ColDefFactory().createColDefs(this), rowData: new RowDataFactory().createRowData(this), icons: { columnRemoveFromGroup: '', filter: '', sortAscending: '', sortDescending: '', groupExpanded: '', groupContracted: '', columnGroupOpened: '', columnGroupClosed: '' } }; // the grid options are optional, because you can provide every property // to the grid via standard React properties. however, the react interface // doesn't block you from using the standard JavaScript interface if you // wish. Maybe you have the gridOptions stored as JSON on your server? If // you do, the providing the gridOptions as a standalone object is just // what you want! this.gridOptions = { // this is how you listen for events using gridOptions onModelUpdated: function() { console.log('event onModelUpdated received'); }, // this is a simple property rowBuffer: 10 // no need to set this, the default is fine for almost all scenarios }; } onShowGrid(show) { this.setState({ showGrid: show }); } onToggleToolPanel(event) { this.setState({showToolPanel: event.target.checked}); } onGridReady(params) { this.api = params.api; this.columnApi = params.columnApi; } selectAll() { this.api.selectAll(); } deselectAll() { this.api.deselectAll(); } setCountryVisible(visible) { this.columnApi.setColumnVisible('country', visible); } onQuickFilterText(event) { this.setState({quickFilterText: event.target.value}); } onCellClicked(event) { console.log('onCellClicked: ' + event.data.name + ', col ' + event.colIndex); } onRowSelected(event) { console.log('onRowSelected: ' + event.node.data.name); } onRefreshData() { var newRowData = new RowDataFactory().createRowData(); this.setState({ rowData: newRowData }); } render() { var gridTemplate; var bottomHeaderTemplate; var topHeaderTemplate; topHeaderTemplate = (
Employees Skills and Contact Details
); // showing the bottom header and grid is optional, so we put in a switch if (this.state.showGrid) { bottomHeaderTemplate = (
Grid API: Column API:
); gridTemplate = (
); } return
{topHeaderTemplate} {bottomHeaderTemplate} {gridTemplate}
; } }