)
- }
-
- let example = null;
- switch (this.state.example) {
- case 'dynamic':
- example = ;
- break;
- case 'rich-dynamic':
- example = ;
- break;
- case 'editor':
- example = ;
- break;
- case 'pinned-row':
- example = ;
- break;
- case 'full-width':
- example = ;
- break;
- case 'group-row':
- example = ;
- break;
- case 'filter':
- example = ;
- break;
- case 'master-detail':
- example = ;
- break;
- case 'simple-redux':
- example = ;
- break;
- case 'floating-filter':
- example = ;
- break;
- case 'simple-redux-dynamic':
- example = ;
- break;
- default:
- example = ;
- }
-
- return (
-
- {header}
- {example}
-
- )
- }
-}
-
-export default App
-*/
diff --git a/src/index.js b/src/index.js
index 36350b3..fe54af5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -4,8 +4,8 @@ import React from "react";
import {render} from "react-dom";
import {BrowserRouter} from "react-router-dom";
-import "ag-grid-root/dist/styles/ag-grid.css";
-import "ag-grid-root/dist/styles/theme-fresh.css";
+import "ag-grid/dist/styles/ag-grid.css";
+import "ag-grid/dist/styles/theme-fresh.css";
import "../node_modules/bootstrap/dist/css/bootstrap.css";
import App from "./App";
diff --git a/src/richGridDeclarativeExample/DateComponent.jsx b/src/richGridDeclarativeExample/DateComponent.jsx
new file mode 100644
index 0000000..ba5145e
--- /dev/null
+++ b/src/richGridDeclarativeExample/DateComponent.jsx
@@ -0,0 +1,171 @@
+import React from "react";
+import * as PropTypes from "prop-types";
+
+// Date Component to be used in the date filter.
+// This is a very simple example of how a React component can be plugged as a DateComponentFramework
+// as you can see, the only requirement is that the React component implements the required methods
+// getDate and setDate and that it calls back into props.onDateChanged every time that the date changes.
+export default class DateComponent extends React.Component {
+
+ constructor(props) {
+ super(props);
+ //The state of this component is represented of:
+ // The current date it holds, null by default, null if the date typed by the user is not valid or fields are blank
+ // The current values that the user types in the input boxes, by default ''
+
+ //The textBoxes state is necessary since it can be set from ag-Grid. This can be seen in this example through
+ // the usage of the button DOB equals to 01/01/2000 in the example page.
+ this.state = {
+ date: null,
+ textBoxes: {
+ dd: '',
+ mm: '',
+ yyyy: ''
+ }
+ }
+ }
+
+ render() {
+ //Inlining styles to make simpler the component
+ let filterStyle = {
+ margin: '2px'
+ };
+ let ddStyle = {
+ width: '30px'
+ };
+ let mmStyle = {
+ width: '30px'
+ };
+ let yyyyStyle = {
+ width: '40px'
+ };
+ let resetStyle = {
+ padding: '2px',
+ backgroundColor: 'red',
+ borderRadius: '3px',
+ fontSize: '10px',
+ marginRight: '5px',
+ color: 'white'
+ };
+
+ return (
+
+ x
+ /
+ /
+
+
+ );
+ }
+
+ //*********************************************************************************
+ // METHODS REQUIRED BY AG-GRID
+ //*********************************************************************************
+
+ getDate() {
+ //ag-grid will call us here when in need to check what the current date value is hold by this
+ //component.
+ return this.state.date;
+ }
+
+ setDate(date) {
+ //ag-grid will call us here when it needs this component to update the date that it holds.
+ this.setState({
+ date,
+ textBoxes: {
+ dd: date ? date.getDate() : '',
+ mm: date ? date.getMonth() + 1 : '',
+ yyyy: date ? date.getFullYear() : ''
+ }
+ })
+ }
+
+ //*********************************************************************************
+ // LINKS THE INTERNAL STATE AND AG-GRID
+ //*********************************************************************************
+
+ updateAndNotifyAgGrid(date, textBoxes) {
+ this.setState({
+ date: date,
+ textBoxes: textBoxes
+ },
+ //Callback after the state is set. This is where we tell ag-grid that the date has changed so
+ //it will proceed with the filtering and we can then expect ag-Grid to call us back to getDate
+ this.props.onDateChanged
+ );
+ }
+
+
+ //*********************************************************************************
+ // LINKING THE UI, THE STATE AND AG-GRID
+ //*********************************************************************************
+
+ resetDate() {
+ let date = null;
+ let textBoxes = {
+ dd: '',
+ mm: '',
+ yyyy: '',
+ };
+
+ this.updateAndNotifyAgGrid(date, textBoxes)
+ }
+
+ onDateChanged() {
+ let date = this.parseDate(this.refs.dd.value, this.refs.mm.value, this.refs.yyyy.value);
+ let textBoxes = {
+ dd: this.refs.dd.value,
+ mm: this.refs.mm.value,
+ yyyy: this.refs.yyyy.value,
+ };
+
+ this.updateAndNotifyAgGrid(date, textBoxes)
+ }
+
+ //*********************************************************************************
+ // INTERNAL LOGIC
+ //*********************************************************************************
+
+ parseDate(dd, mm, yyyy) {
+ //If any of the three input date fields are empty, stop and return null
+ if (dd.trim() === '' || mm.trim() === '' || yyyy.trim() === '') {
+ return null;
+ }
+
+ let day = Number(dd);
+ let month = Number(mm);
+ let year = Number(yyyy);
+
+ let date = new Date(year, month - 1, day);
+
+ //If the date is not valid
+ if (isNaN(date.getTime())) {
+ return null;
+ }
+
+ //Given that new Date takes any garbage in, it is possible for the user to specify a new Date
+ //like this (-1, 35, 1) and it will return a valid javascript date. In this example, it will
+ //return Sat Dec 01 1 00:00:00 GMT+0000 (GMT) - Go figure...
+ //To ensure that we are not letting non sensical dates to go through we check that the resultant
+ //javascript date parts (month, year and day) match the given date fields provided as parameters.
+ //If the javascript date parts don't match the provided fields, we assume that the input is non
+ //sensical... ie: Day=-1 or month=14, if this is the case, we return null
+ //This also protects us from non sensical dates like dd=31, mm=2 of any year
+ if (date.getDate() != day || date.getMonth() + 1 != month || date.getFullYear() != year) {
+ return null;
+ }
+
+ return date;
+ }
+}
+
+// the grid will always pass in one props called 'params',
+// which is the grid passing you the params for the cellRenderer.
+// this piece is optional. the grid will always pass the 'params'
+// props, so little need for adding this validation meta-data.
+DateComponent.propTypes = {
+ params: PropTypes.object
+};
\ No newline at end of file
diff --git a/src/richGridDeclarativeExample/HeaderGroupComponent.jsx b/src/richGridDeclarativeExample/HeaderGroupComponent.jsx
new file mode 100644
index 0000000..30fc1da
--- /dev/null
+++ b/src/richGridDeclarativeExample/HeaderGroupComponent.jsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import * as PropTypes from 'prop-types';
+
+// Header component to be used as default for all the columns.
+export default class HeaderGroupComponent extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.props.columnGroup.getOriginalColumnGroup().addEventListener('expandedChanged', this.onExpandChanged.bind(this));
+ this.state = {
+ expanded: null
+ };
+ }
+
+ componentDidMount() {
+ this.onExpandChanged();
+ }
+
+ render() {
+ let arrowClassName = "customExpandButton " + (this.state.expanded ? " expanded" : " collapsed");
+
+ return
+
{this.props.displayName}
+
+
+ }
+
+ expandOrCollapse() {
+ this.props.setExpanded(!this.state.expanded);
+ };
+
+ onExpandChanged() {
+ this.setState({
+ expanded: this.props.columnGroup.getOriginalColumnGroup().isExpanded()
+ })
+ }
+}
+
+// the grid will always pass in one props called 'params',
+// which is the grid passing you the params for the cellRenderer.
+// this piece is optional. the grid will always pass the 'params'
+// props, so little need for adding this validation meta-data.
+HeaderGroupComponent.propTypes = {
+ params: PropTypes.object
+};
\ No newline at end of file
diff --git a/src/richGridDeclarativeExample/NameCellEditor.jsx b/src/richGridDeclarativeExample/NameCellEditor.jsx
new file mode 100644
index 0000000..b7c2a65
--- /dev/null
+++ b/src/richGridDeclarativeExample/NameCellEditor.jsx
@@ -0,0 +1,117 @@
+import React from 'react';
+import * as PropTypes from 'prop-types';
+
+const KEY_BACKSPACE = 8;
+const KEY_DELETE = 46;
+const KEY_F2 = 113;
+
+// cell renderer for the proficiency column. this is a very basic cell editor,
+export default class NameCellEditor extends React.Component {
+
+ constructor(props) {
+ super(props);
+ // the entire ag-Grid properties are passed as one single object inside the params
+ this.state = this.createInitialState(props);
+ }
+
+ // work out how to present the data based on what the user hit. you don't need to do any of
+ // this for your ag-Grid cellEditor to work, however it makes sense to do this so the user
+ // experience is similar to Excel
+ createInitialState(props) {
+
+ let startValue;
+ const putCursorAtEndOnFocus = false;
+ const highlightAllOnFocus = false;
+
+ if (props.keyPress === KEY_BACKSPACE || props.keyPress === KEY_DELETE) {
+ // if backspace or delete pressed, we clear the cell
+ startValue = '';
+ } else if (props.charPress) {
+ // if a letter was pressed, we start with the letter
+ startValue = props.charPress;
+ } else {
+ // otherwise we start with the current value
+ startValue = props.value;
+ if (props.keyPress === KEY_F2) {
+ this.putCursorAtEndOnFocus = true;
+ } else {
+ this.highlightAllOnFocus = true;
+ }
+ }
+
+ return {
+ value: startValue,
+ putCursorAtEndOnFocus: putCursorAtEndOnFocus,
+ highlightAllOnFocus: highlightAllOnFocus
+ }
+ }
+
+ render() {
+ return (
+
+ );
+ }
+
+ onChangeListener(event) {
+ // if doing React, you will probably be using a library for managing immutable
+ // objects better. to keep this example simple, we don't use one.
+ const newState = {
+ value: event.target.value,
+ putCursorAtEndOnFocus: this.state.putCursorAtEndOnFocus,
+ highlightAllOnFocus: this.state.highlightAllOnFocus
+ };
+ this.setState(newState);
+ }
+
+ // called by ag-Grid, to get the final value
+ getValue() {
+ return this.state.value;
+ }
+
+ // cannot use componentDidMount because although the component might be ready from React's point of
+ // view, it may not yet be in the browser (put in by ag-Grid) so focus will not work
+ afterGuiAttached() {
+ // get ref from React component
+ const eInput = this.refs.textField;
+ eInput.focus();
+ if (this.highlightAllOnFocus) {
+ eInput.select();
+ } else {
+ // when we started editing, we want the carot at the end, not the start.
+ // this comes into play in two scenarios: a) when user hits F2 and b)
+ // when user hits a printable character, then on IE (and only IE) the carot
+ // was placed after the first character, thus 'apply' would end up as 'pplea'
+ const length = eInput.value ? eInput.value.length : 0;
+ if (length > 0) {
+ eInput.setSelectionRange(length, length);
+ }
+ }
+ }
+
+ // if we want the editor to appear in a popup, then return true.
+ isPopup() {
+ return false;
+ }
+
+ // return true here if you don't want to allow editing on the cell.
+ isCancelBeforeStart() {
+ return false;
+ }
+
+ // just to demonstrate, if you type in 'cancel' then the edit will not take effect
+ isCancelAfterEnd() {
+ if (this.state.value && this.state.value.toUpperCase() === 'CANCEL') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+// the grid will always pass in one props called 'params',
+// which is the grid passing you the params for the cellRenderer.
+// this piece is optional. the grid will always pass the 'params'
+// props, so little need for adding this validation meta-data.
+NameCellEditor.propTypes = {
+ params: PropTypes.object
+};
\ No newline at end of file
diff --git a/src/richGridDeclarativeExample/ProficiencyCellRenderer.jsx b/src/richGridDeclarativeExample/ProficiencyCellRenderer.jsx
new file mode 100644
index 0000000..d2760de
--- /dev/null
+++ b/src/richGridDeclarativeExample/ProficiencyCellRenderer.jsx
@@ -0,0 +1,24 @@
+import React from 'react';
+
+// cell renderer for the proficiency column. this is a very basic cell renderer,
+// it is arguable that we should not of used React and just returned a string of
+// html as a normal ag-Grid cellRenderer.
+export default class ProficiencyCellRenderer extends React.Component {
+
+ render() {
+ let backgroundColor;
+ if (this.props.value < 20) {
+ backgroundColor = 'red';
+ } else if (this.props.value < 60) {
+ backgroundColor = '#ff9900';
+ } else {
+ backgroundColor = '#00A000';
+ }
+
+ return (
+
+
{this.props.value}%
+
+ );
+ }
+}
diff --git a/src/richGridDeclarativeExample/ProficiencyFilter.jsx b/src/richGridDeclarativeExample/ProficiencyFilter.jsx
new file mode 100644
index 0000000..b2d2900
--- /dev/null
+++ b/src/richGridDeclarativeExample/ProficiencyFilter.jsx
@@ -0,0 +1,90 @@
+import React from 'react';
+
+const PROFICIENCY_NAMES = ['No Filter', 'Above 40%', 'Above 60%', 'Above 80%'];
+
+// the proficiency filter component. this demonstrates how to integrate
+// a React filter component with ag-Grid.
+export default class ProficiencyFilter extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ selected: PROFICIENCY_NAMES[0]
+ };
+ }
+
+ // called by agGrid
+ doesFilterPass(params) {
+ const value = this.props.valueGetter(params);
+ const valueAsNumber = parseFloat(value);
+
+ switch (this.state.selected) {
+ case PROFICIENCY_NAMES[1] :
+ return valueAsNumber >= 40;
+ case PROFICIENCY_NAMES[2] :
+ return valueAsNumber >= 60;
+ case PROFICIENCY_NAMES[3] :
+ return valueAsNumber >= 80;
+ default :
+ return true;
+ }
+ };
+
+ // called by agGrid
+ isFilterActive() {
+ return this.state.selected !== PROFICIENCY_NAMES[0];
+ };
+
+ onButtonPressed(name) {
+ const newState = {selected: name};
+ // set the state, and once it is done, then call filterChangedCallback
+ this.setState(newState, this.props.filterChangedCallback);
+ }
+
+
+ getModel() {
+ return ''
+ }
+
+ setModel(model) {
+ }
+
+ render() {
+ const rows = [];
+ PROFICIENCY_NAMES.forEach((name) => {
+ const selected = this.state.selected === name;
+ rows.push(
+
+ );
+ }
+}
diff --git a/src/richGridDeclarativeExample/RowDataFactory.js b/src/richGridDeclarativeExample/RowDataFactory.js
new file mode 100644
index 0000000..27ff58e
--- /dev/null
+++ b/src/richGridDeclarativeExample/RowDataFactory.js
@@ -0,0 +1,45 @@
+import RefData from './RefData';
+
+export default class RowDataFactory {
+
+ createRowData() {
+ const rowData = [];
+
+ for (let i = 0; i < 200; i++) {
+ const countryData = RefData.COUNTRIES[i % RefData.COUNTRIES.length];
+ rowData.push({
+ name: RefData.FIRST_NAMES[i % RefData.FIRST_NAMES.length] + ' ' + RefData.LAST_NAMES[i % RefData.LAST_NAMES.length],
+ skills: {
+ android: Math.random() < 0.4,
+ html5: Math.random() < 0.4,
+ mac: Math.random() < 0.4,
+ windows: Math.random() < 0.4,
+ css: Math.random() < 0.4
+ },
+ dob: RefData.DOB[i % RefData.DOB.length],
+ address: RefData.ADDRESSES[i % RefData.ADDRESSES.length],
+ years: Math.round(Math.random() * 100),
+ proficiency: Math.round(Math.random() * 100),
+ country: countryData.country,
+ continent: countryData.continent,
+ language: countryData.language,
+ mobile: this.createRandomPhoneNumber(),
+ landline: this.createRandomPhoneNumber()
+ });
+ }
+
+ return rowData;
+ }
+
+ createRandomPhoneNumber() {
+ let result = '+';
+ for (let i = 0; i < 12; i++) {
+ result += Math.round(Math.random() * 10);
+ if (i === 2 || i === 5 || i === 8) {
+ result += ' ';
+ }
+ }
+ return result;
+ }
+
+}
\ No newline at end of file
diff --git a/src/richGridDeclarativeExample/SkillsCellRenderer.jsx b/src/richGridDeclarativeExample/SkillsCellRenderer.jsx
new file mode 100644
index 0000000..7c22d51
--- /dev/null
+++ b/src/richGridDeclarativeExample/SkillsCellRenderer.jsx
@@ -0,0 +1,27 @@
+import React from 'react';
+import * as PropTypes from 'prop-types';
+import RefData from './RefData';
+
+export default class SkillsCellRenderer extends React.Component {
+
+ render() {
+ const skills = [];
+ const rowData = this.props.data;
+ RefData.IT_SKILLS.forEach((skill) => {
+ if (rowData && rowData.skills && rowData.skills[skill]) {
+ skills.push();
+ }
+ });
+
+ return {skills};
+ }
+
+}
+
+// the grid will always pass in one props called 'params',
+// which is the grid passing you the params for the cellRenderer.
+// this piece is optional. the grid will always pass the 'params'
+// props, so little need for adding this validation meta-data.
+SkillsCellRenderer.propTypes = {
+ params: PropTypes.object
+};
\ No newline at end of file
diff --git a/src/richGridDeclarativeExample/SkillsFilter.jsx b/src/richGridDeclarativeExample/SkillsFilter.jsx
new file mode 100644
index 0000000..cb44c89
--- /dev/null
+++ b/src/richGridDeclarativeExample/SkillsFilter.jsx
@@ -0,0 +1,126 @@
+import React from 'react';
+import RefData from './RefData';
+
+// the skills filter component. this can be laid out much better in a 'React'
+// way. there are design patterns you can apply to layout out your React classes.
+// however, i'm not worried, as the intention here is to show you ag-Grid
+// working with React, and that's all. i'm not looking for any awards for my
+// React design skills.
+export default class SkillsFilter extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ android: false,
+ css: false,
+ html5: false,
+ mac: false,
+ windows: false
+ };
+ }
+
+ getModel() {
+ return {
+ android: this.state.android,
+ css: this.state.css,
+ html5: this.state.html5,
+ mac: this.state.mac,
+ windows: this.state.windows
+ }
+ }
+
+ setModel(model) {
+ this.setState({
+ android: model ? model.android : null,
+ css: model ? model.css : null,
+ html5: model ? model.html5 : null,
+ mac: model ? model.mac : null,
+ windows: model ? model.windows : null
+ });
+ }
+
+ // called by agGrid
+ doesFilterPass(params) {
+
+ const rowSkills = params.data.skills;
+ let passed = true;
+
+ RefData.IT_SKILLS.forEach((skill) => {
+ if (this.state[skill]) {
+ if (!rowSkills[skill]) {
+ passed = false;
+ }
+ }
+ });
+
+ return passed;
+ };
+
+ getModel() {
+ return ''
+ }
+
+ // called by agGrid
+ isFilterActive() {
+ const somethingSelected = this.state.android || this.state.css ||
+ this.state.html5 || this.state.mac || this.state.windows;
+ return somethingSelected;
+ };
+
+ onSkillChanged(skill, event) {
+ const newValue = event.target.checked;
+ const newModel = {};
+ newModel[skill] = newValue;
+ // set the state, and once it is done, then call filterChangedCallback
+ this.setState(newModel, this.props.filterChangedCallback);
+ }
+
+ helloFromSkillsFilter() {
+ alert("Hello From The Skills Filter!");
+ }
+
+ render() {
+
+ const skillsTemplates = [];
+ RefData.IT_SKILLS.forEach((skill, index) => {
+
+ const skillName = RefData.IT_SKILLS_NAMES[index];
+ const template = (
+
+ );
+
+ skillsTemplates.push(template);
+ });
+
+ return (
+
+
+ Custom Skills Filter
+
+ {skillsTemplates}
+
+ );
+ }
+
+ // these are other method that agGrid calls that we
+ // could of implemented, but they are optional and
+ // we have no use for them in this particular filter.
+ //afterGuiAttached(params) {}
+ //onNewRowsLoaded() {}
+ //onAnyFilterChanged() {}
+}
diff --git a/src/richGridDeclarativeExample/SortableHeaderComponent.jsx b/src/richGridDeclarativeExample/SortableHeaderComponent.jsx
new file mode 100644
index 0000000..fe88a5a
--- /dev/null
+++ b/src/richGridDeclarativeExample/SortableHeaderComponent.jsx
@@ -0,0 +1,89 @@
+import React from "react";
+import * as PropTypes from "prop-types";
+
+// Header component to be used as default for all the columns.
+export default class SortableHeaderComponent extends React.Component {
+
+ constructor(props) {
+ super(props);
+
+ // this.sortChanged = this.onSortChanged.bind(this);
+ this.props.column.addEventListener('sortChanged', this.onSortChanged);
+
+ //The state of this component contains the current sort state of this column
+ //The possible values are: 'asc', 'desc' and ''
+ this.state = {
+ sorted: ''
+ }
+ }
+
+ componentWillUnmount() {
+ this.props.column.removeEventListener('sortChanged', this.onSortChanged);
+ }
+
+ render() {
+ let sortElements = [];
+ if (this.props.enableSorting) {
+ let downArrowClass = "customSortDownLabel " + (this.state.sorted === 'desc' ? " active" : "");
+ let upArrowClass = "customSortUpLabel " + (this.state.sorted === 'asc' ? " active" : "");
+ let removeArrowClass = "customSortRemoveLabel " + (this.state.sorted === '' ? " active" : "");
+
+ sortElements.push(
);
+ sortElements.push(
);
+ sortElements.push(
)
+ }
+
+
+ let menuButton = null;
+ if (this.props.enableMenu) {
+ menuButton =
+
+ }
+
+ return
+ {menuButton}
+
{this.props.displayName}
+ {sortElements}
+
+ }
+
+ onSortRequested(order, event) {
+ this.props.setSort(order, event.shiftKey);
+ };
+
+ onSortChanged = () => {
+ if (this.props.column.isSortAscending()) {
+ this.setState({
+ sorted: 'asc'
+ })
+ } else if (this.props.column.isSortDescending()) {
+ this.setState({
+ sorted: 'desc'
+ })
+ } else {
+ this.setState({
+ sorted: ''
+ })
+ }
+ };
+
+ onMenuClick() {
+ this.props.showColumnMenu(this.refs.menuButton);
+ };
+
+}
+
+// the grid will always pass in one props called 'params',
+// which is the grid passing you the params for the cellRenderer.
+// this piece is optional. the grid will always pass the 'params'
+// props, so little need for adding this validation meta-data.
+SortableHeaderComponent.propTypes = {
+ params: PropTypes.object
+};
\ No newline at end of file
diff --git a/src/richGridExample/ColDefFactory.jsx b/src/richGridExample/ColDefFactory.jsx
index 5d60678..15e0ea5 100644
--- a/src/richGridExample/ColDefFactory.jsx
+++ b/src/richGridExample/ColDefFactory.jsx
@@ -7,7 +7,6 @@ import ProficiencyFilter from './ProficiencyFilter.jsx';
import HeaderGroupComponent from './HeaderGroupComponent.jsx';
export default class ColDefFactory {
-
createColDefs() {
return [
{
@@ -51,7 +50,7 @@ export default class ColDefFactory {
{
headerName: "DOB",
field: "dob",
- width: 110,
+ width: 145,
enableRowGroup: true,
enablePivot: true,
filter: 'date',
diff --git a/src/richGridExample/DateComponent.jsx b/src/richGridExample/DateComponent.jsx
index 5ae4328..ba5145e 100644
--- a/src/richGridExample/DateComponent.jsx
+++ b/src/richGridExample/DateComponent.jsx
@@ -37,7 +37,7 @@ export default class DateComponent extends React.Component {
width: '30px'
};
let yyyyStyle = {
- width: '60px'
+ width: '40px'
};
let resetStyle = {
padding: '2px',
diff --git a/src/richGridExample/RichGridExample.jsx b/src/richGridExample/RichGridExample.jsx
index d11a214..3586571 100644
--- a/src/richGridExample/RichGridExample.jsx
+++ b/src/richGridExample/RichGridExample.jsx
@@ -54,56 +54,50 @@ export default class RichGridExample extends Component {
rowBuffer: 10, // no need to set this, the default is fine for almost all scenarios,
floatingFilter: true
};
-
- this.onGridReady = this.onGridReady.bind(this);
- this.onRowSelected = this.onRowSelected.bind(this);
- this.onCellClicked = this.onCellClicked.bind(this);
}
- onToggleToolPanel(event) {
- this.setState({showToolPanel: event.target.checked});
- }
- onGridReady(params) {
+ /* Grid Events we're listening to */
+ onGridReady = (params) => {
this.api = params.api;
this.columnApi = params.columnApi;
- }
+ };
+
+ onCellClicked = (event) => {
+ console.log('onCellClicked: ' + event.data.name + ', col ' + event.colIndex);
+ };
+
+ onRowSelected = (event) => {
+ console.log('onRowSelected: ' + event.node.data.name);
+ };
+
+ /* Demo related methods */
+ onToggleToolPanel = (event) => {
+ this.setState({showToolPanel: event.target.checked});
+ };
deselectAll() {
this.api.deselectAll();
}
- setCountryVisible(visible) {
- this.columnApi.setColumnVisible('country', visible);
- }
-
- onQuickFilterText(event) {
+ 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() {
- let newRowData = new RowDataFactory().createRowData();
+ onRefreshData = () => {
this.setState({
- rowData: newRowData
+ rowData: new RowDataFactory().createRowData()
});
- }
+ };
- invokeSkillsFilterMethod() {
+ invokeSkillsFilterMethod = () => {
let skillsFilter = this.api.getFilterInstance('skills');
let componentInstance = skillsFilter.getFrameworkComponentInstance();
componentInstance.helloFromSkillsFilter();
- }
+ };
- dobFilter() {
- let dateFilterComponent = this.gridOptions.api.getFilterInstance('dob');
+ dobFilter = () => {
+ let dateFilterComponent = this.api.getFilterInstance('dob');
dateFilterComponent.setFilterType('equals');
dateFilterComponent.setDateFrom('2000-01-01');
@@ -111,14 +105,14 @@ export default class RichGridExample extends Component {
// to allow time for the state to be set (as setState is an async operation)
// simply wait for the next tick
setTimeout(() => {
- this.gridOptions.api.onFilterChanged();
+ this.api.onFilterChanged();
}, 0)
- }
+ };
render() {
return (
-
Rich Grid Example
+
Rich Grid with Declarative Markup Example
Employees Skills and Contact Details
@@ -128,42 +122,34 @@ export default class RichGridExample extends Component {
Grid API:
-
-
+
+
Column API:
-
-
+
+
-
+
-
+
Filter API:
-
-
+
@@ -190,14 +176,14 @@ export default class RichGridExample extends Component {
rowData={this.state.rowData}
// no binding, just providing hard coded strings for the properties
- suppressRowClickSelection="true"
+ // boolean properties will default to true if provided (ie enableColResize => enableColResize="true")
+ suppressRowClickSelection
rowSelection="multiple"
- enableColResize="true"
- enableSorting="true"
- enableFilter="true"
- groupHeaders="true"
- rowHeight="22"
- />
+ enableColResize
+ enableSorting
+ enableFilter
+ groupHeaders
+ rowHeight="22"/>