AG-643 Tidy React examples

This commit is contained in:
Sean Landsman
2017-07-25 12:47:07 +01:00
parent a70f248af5
commit 79b0eda61b
6 changed files with 40 additions and 29 deletions

View File

@@ -0,0 +1,85 @@
import React, {Component} from "react";
import {AgGridReact} from "ag-grid-react";
import StyledRenderer from "./StyledRenderer";
export default class PinnedRowComponentExample extends Component {
constructor(props) {
super(props);
this.state = {
gridOptions: {},
rowData: this.createRowData(),
columnDefs: this.createColumnDefs(),
pinnedTopRowData: [{row: "Top Row", number: "Top Number"}],
pinnedBottomRowData: [{row: "Bottom Row", number: "Bottom Number"}]
};
this.onGridReady = this.onGridReady.bind(this);
}
onGridReady(params) {
this.gridApi = params.api;
this.columnApi = params.columnApi;
this.gridApi.sizeColumnsToFit();
}
createColumnDefs() {
return [
{
headerName: "Row",
field: "row",
width: 400,
pinnedRowCellRendererFramework: StyledRenderer,
pinnedRowCellRendererParams: {
style: {'fontWeight': 'bold'}
}
},
{
headerName: "Number",
field: "number",
width: 399,
pinnedRowCellRendererFramework: StyledRenderer,
pinnedRowCellRendererParams: {
style: {'fontStyle': 'italic'}
}
},
];
}
createRowData() {
let rowData = [];
for (let i = 0; i < 15; i++) {
rowData.push({
row: "Row " + i,
number: Math.round(Math.random() * 100)
});
}
return rowData;
}
render() {
return (
<div style={{height: 400, width: 945}}
className="ag-fresh">
<h1>Pinned Row Renderer Example</h1>
<AgGridReact
// properties
columnDefs={this.state.columnDefs}
rowData={this.state.rowData}
pinnedTopRowData={this.state.pinnedTopRowData}
pinnedBottomRowData={this.state.pinnedBottomRowData}
// events
onGridReady={this.onGridReady}>
</AgGridReact>
</div>
);
}
};

View File

@@ -0,0 +1,13 @@
import React, {Component} from "react";
export default class CurrencyRenderer extends Component {
constructor(props) {
super(props);
}
render() {
return (
<span style={this.props.style}>{this.props.value}</span>
);
}
};