Compare commits

...

20 Commits

Author SHA1 Message Date
Alberto
5a45846cb7 Release 13.0.1 2017-08-29 15:27:33 +02:00
Petyo Ivanov
2d8d5b125e Removed legacy padding 2017-08-29 13:34:18 +03:00
Alberto
818b7798ee Merge branch 'latest' into 13.0.0
# Conflicts:
#	package.json
2017-08-25 16:59:25 +02:00
Sean Landsman
15ba8d7e60 Rename cellFormatter to valueFormatter 2017-08-23 14:04:13 +01:00
Alberto
eab958c3e9 Releasing 13.0.0 2017-08-23 11:35:39 +01:00
Sean Landsman
3a17b7f638 AG-668 Update all README.md to point to appropriate plunker/seed 2017-08-21 11:45:09 +01:00
Sean Landsman
734d39e2d7 AG-676 Move framework examples into parent folder for easier exclusion 2017-08-17 11:04:12 +01:00
Sean Landsman
0d7cace354 Add example for keypress in editors
https://github.com/ag-grid/ag-grid-react/issues/60
2017-08-10 16:02:03 +01:00
Sean Landsman
fa0881bfcf Merge remote-tracking branch 'origin/latest' into latest 2017-08-10 15:51:05 +01:00
Sean Landsman
62b9e3582a Add example for keypress in editors
https://github.com/ag-grid/ag-grid-react/issues/60
2017-08-10 15:50:54 +01:00
Petyo Ivanov
949797d4be rename repo from ceolter to ag-grid 2017-08-04 12:23:47 +01:00
Sean Landsman
a869fe3819 CI Work 2017-08-02 13:48:39 +01:00
Sean Landsman
c611af4f39 CI Work 2017-08-02 13:15:55 +01:00
Sean Landsman
7cab3190ae CI Work 2017-08-02 12:19:07 +01:00
Sean Landsman
71fe653fcb CI Work 2017-08-02 11:55:18 +01:00
Sean Landsman
ba1c213ce0 Change selectAll to use refs to expand on example 2017-07-27 08:17:15 +01:00
Sean Landsman
46217c9ad7 Fix sorting issue 2017-07-26 12:10:12 +01:00
Sean Landsman
017642e4d7 AG-643 Tidy React examples 2017-07-25 12:47:47 +01:00
Sean Landsman
79b0eda61b AG-643 Tidy React examples 2017-07-25 12:47:07 +01:00
Sean Landsman
a70f248af5 AG-642 Remove deprecation warning in preparation for 16.x 2017-07-25 12:46:21 +01:00
16 changed files with 193 additions and 88 deletions

26
gulpfile.js Normal file
View File

@@ -0,0 +1,26 @@
const gulp = require('gulp');
const gulpTypescript = require('gulp-typescript');
const merge = require('merge2');
gulp.task('watch', watchTask);
gulp.task('rebuild-ag-grid-react', rebuildAgGridReact);
const tsConfig = '../ag-grid-react/tsconfig.json';
const tsProject = gulpTypescript.createProject(tsConfig);
function rebuildAgGridReact() {
const tsResult = gulp
.src('../ag-grid-react/src/**/*.ts')
.pipe(tsProject());
return merge([
tsResult.dts
.pipe(gulp.dest('node_modules/ag-grid-react/lib')),
tsResult.js
.pipe(gulp.dest('node_modules/ag-grid-react/lib'))
]);
}
function watchTask() {
gulp.watch(['../ag-grid-react/src/**/*'], rebuildAgGridReact);
}

View File

@@ -1,6 +1,6 @@
{
"name": "ag-grid-react-example",
"version": "12.0.0",
"version": "13.0.1",
"description": "Example Reach applicaiton using ag-Grid.",
"main": "dist/ag-grid-react-example.js",
"scripts": {
@@ -12,17 +12,18 @@
"copy-examples": "ncp images dist/examples/images && ncp src/index.html dist/examples/index.html && ncp dist/react-examples.js dist/examples/dist/react-examples.js && ncp src dist/examples/src",
"copy-trader": "ncp src-trader-dashboard/index.html dist/trader/index.html && ncp dist/react-trader.js dist/trader/dist/react-trader.js",
"copy": "npm run copy-examples && npm run copy-trader",
"build-large": "webpack --config webpack.config.large.js --progress --profile --bail",
"build-examples": "webpack --config webpack.config.examples.js --progress --profile --bail",
"build-dashboard": "webpack --config webpack.config.trader.js --progress --profile --bail",
"build-all": "npm run build-examples && npm run build-dashboard",
"build": "npm run clean && npm run mkdirs && npm run build-all && npm run copy",
"copy-to-docs": "ncp dist/examples ../ag-grid-docs/src/react-examples/examples && ncp dist/trader ../ag-grid-docs/src/react-examples/trader",
"copy-to-docs": "ncp dist/examples ../ag-grid-docs/src/framework-examples/react-examples/examples && ncp dist/trader ../ag-grid-docs/src/framework-examples/react-examples/trader",
"build-to-docs": "npm run build && npm run copy-to-docs",
"start": "npm run examples"
},
"repository": {
"type": "git",
"url": "https://github.com/ceolter/ag-grid-react-example.git"
"url": "https://github.com/ag-grid/ag-grid-react-example.git"
},
"keywords": [
"react",
@@ -33,7 +34,7 @@
"author": "Niall Crosby <niall.crosby@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/ceolter/ag-grid-react-example/issues"
"url": "https://github.com/ag-grid/ag-grid-react-example/issues"
},
"homepage": "http://www.ag-grid.com/",
"devDependencies": {
@@ -43,29 +44,32 @@
"babel-preset-react": "6.24.x",
"babel-preset-stage-0": "6.24.x",
"babel-preset-stage-1": "6.24.x",
"prop-types": "15.5.x",
"css-loader": "0.23.x",
"mkdirp": "0.5.1",
"ncp": "2.0.0",
"prop-types": "15.5.x",
"rimraf": "2.5.x",
"style-loader": "0.13.x",
"webpack": "1.12.x",
"webpack-dev-server": "1.14.x"
"webpack-dev-server": "1.14.x",
"gulp": "3.9.x",
"gulp-typescript": "3.1.x",
"merge2": "1.0.x",
"typescript": "2.3.x"
},
"dependencies": {
"bootstrap": "3.3.7",
"d3": "4.9.1",
"file-loader": "0.11.1",
"lodash": "4.17.4",
"react": "15.5.x",
"react-dom": "15.5.x",
"react": "15.6.x",
"react-dom": "15.6.x",
"react-dom-factories": "1.0.0",
"react-redux": "5.0.x",
"redux": "3.6.x",
"url-search-params-polyfill": "1.2.0",
"ag-grid": "12.0.x",
"ag-grid-enterprise": "12.0.x",
"ag-grid-react": "12.0.x"
"ag-grid": "13.0.x",
"ag-grid-enterprise": "13.0.x",
"ag-grid-react": "13.0.x"
}
}

View File

@@ -23,21 +23,21 @@ export default class extends Component {
{
field: 'price',
headerName: 'Price',
cellFormatter: this.numberFormatter,
valueFormatter: this.numberFormatter,
cellRenderer: 'animateShowChange',
cellStyle: {'text-align': 'right'}
},
{
field: 'bid',
headerName: 'Bid',
cellFormatter: this.numberFormatter,
valueFormatter: this.numberFormatter,
cellRenderer: 'animateShowChange',
cellStyle: {'text-align': 'right'}
},
{
field: 'ask',
headerName: 'Ask',
cellFormatter: this.numberFormatter,
valueFormatter: this.numberFormatter,
cellRenderer: 'animateShowChange',
cellStyle: {'text-align': 'right'}
}

View File

@@ -6,13 +6,13 @@ import DynamicComponentsExample from "./dynamicComponentExample/DynamicComponent
import RichGridExample from "./richGridExample/RichGridExample";
import RichComponentsExample from "./richComponentExample/RichComponentsExample";
import EditorComponentsExample from "./editorComponentExample/EditorComponentsExample";
import FloatingRowComponentExample from "./floatingRowExample/FloatingRowComponentExample";
import PinnedRowComponentExample from "./pinnedRowExample/PinnedRowComponentExample";
import FullWidthComponentExample from "./fullWidthExample/FullWidthComponentExample";
import GroupedRowInnerRendererComponentExample from "./groupedRowInnerRendererExample/GroupedRowInnerRendererComponentExample";
import FilterComponentExample from "./filterComponentExample/FilterComponentExample";
import MasterDetailExample from "./masterDetailExample/MasterDetailExample";
import SimpleReduxExample from "./simpleReduxExample/SimpleReduxExample";
import SimpleGridExample from "./floatingFilter/SimpleGridExample";
import FloatingFilterGridExample from "./floatingFilter/FloatingFilterGridExample";
class App extends Component {
constructor(props) {
@@ -45,7 +45,7 @@ class App extends Component {
<li role="presentation" className={this.state.example === 'dynamic' ? 'active' : null} onClick={() => this.setExample("dynamic")}><a href="#">Dynamic React Component Example</a></li>
<li role="presentation" className={this.state.example === 'rich-dynamic' ? 'active' : null} onClick={() => this.setExample("rich-dynamic")}><a href="#">Dynamic React Components - Richer Example</a></li>
<li role="presentation" className={this.state.example === 'editor' ? 'active' : null} onClick={() => this.setExample("editor")}><a href="#">Cell Editor Component Example</a></li>
<li role="presentation" className={this.state.example === 'floating-row' ? 'active' : null} onClick={() => this.setExample("floating-row")}><a href="#">Pinned Row Renderer Example</a></li>
<li role="presentation" className={this.state.example === 'pinned-row' ? 'active' : null} onClick={() => this.setExample("pinned-row")}><a href="#">Pinned Row Renderer Example</a></li>
<li role="presentation" className={this.state.example === 'full-width' ? 'active' : null} onClick={() => this.setExample("full-width")}><a href="#">Full Width Renderer Example</a></li>
<li role="presentation" className={this.state.example === 'group-row' ? 'active' : null} onClick={() => this.setExample("group-row")}><a href="#">Grouped Row Inner Renderer Example</a></li>
<li role="presentation" className={this.state.example === 'filter' ? 'active' : null} onClick={() => this.setExample("filter")}><a href="#">Filters Component Example</a></li>
@@ -66,8 +66,8 @@ class App extends Component {
case 'editor':
example = <EditorComponentsExample/>;
break;
case 'floating-row':
example = <FloatingRowComponentExample/>;
case 'pinned-row':
example = <PinnedRowComponentExample/>;
break;
case 'full-width':
example = <FullWidthComponentExample/>;
@@ -85,7 +85,7 @@ class App extends Component {
example = <SimpleReduxExample/>;
break;
case 'floating-filter':
example = <SimpleGridExample/>;
example = <FloatingFilterGridExample/>;
break;
default:
example = <RichGridExample/>;

View File

@@ -18,9 +18,21 @@ export default class MoodEditor extends Component {
}
componentDidMount() {
this.refs.container.addEventListener('keydown', this.checkAndToggleMoodIfLeftRight);
this.focus();
}
componentWillUnmount() {
this.refs.container.removeEventListener('keydown', this.checkAndToggleMoodIfLeftRight);
}
checkAndToggleMoodIfLeftRight = (event) => {
if ([37, 39].indexOf(event.keyCode) > -1) { // left and right
this.toggleMood();
event.stopPropagation();
}
}
componentDidUpdate() {
this.focus();
}
@@ -75,12 +87,11 @@ export default class MoodEditor extends Component {
background: "#e6e6e6",
padding: 15,
textAlign: "center",
display: "inline-block",
// outline: "none"
display: "inline-block"
};
let unselected = {
paddingLleft: 10,
paddingLeft: 10,
paddingRight: 10,
border: "1px solid transparent",
padding: 4
@@ -93,12 +104,14 @@ export default class MoodEditor extends Component {
padding: 4
};
let happyStyle = this.state.value === 'Happy' ? selected : unselected;
let sadStyle = this.state.value !== 'Happy' ? selected : unselected;
let happyStyle = this.state.happy ? selected : unselected;
let sadStyle = !this.state.happy ? selected : unselected;
return (
<div ref="container"
style={mood}>
style={mood}
tabIndex={1} // important - without this the keypresses wont be caught
>
<img src="images/smiley.png" onClick={this.onHappyClick} style={happyStyle}/>
<img src="images/smiley-sad.png" onClick={this.onSadClick} style={sadStyle}/>
</div>

View File

@@ -16,6 +16,7 @@ export default class MoodEditor extends Component {
}
componentDidMount() {
this.refs.input.addEventListener('keydown', this.onKeyDown);
this.focus();
}
@@ -23,6 +24,10 @@ export default class MoodEditor extends Component {
this.focus();
}
componentWillUnmount() {
this.refs.input.removeEventListener('keydown', this.onKeyDown);
}
focus() {
setTimeout(() => {
let container = ReactDOM.findDOMNode(this.refs.input);
@@ -47,11 +52,20 @@ export default class MoodEditor extends Component {
};
onKeyDown(event) {
if(this.isLeftOrRight(event)) {
event.stopPropagation();
return;
}
if (!this.isKeyPressedNumeric(event)) {
if (event.preventDefault) event.preventDefault();
}
}
isLeftOrRight(event) {
return [37, 39].indexOf(event.keyCode) > -1;
}
handleChange(event) {
this.setState({value: event.target.value});
}
@@ -75,7 +89,6 @@ export default class MoodEditor extends Component {
return (
<input ref="input"
value={this.state.value}
onKeyDown={this.onKeyDown}
onChange={this.handleChange}
/>
);

View File

@@ -1,8 +1,9 @@
import React, {Component} from "react";
import {AgGridReact} from "ag-grid-react";
import FloatingFilter from "./floatingFilter";
import overrideStyle from "./floatingFilter.css";
export default class extends Component {
export default class FloatingFilterGridExample extends Component {
constructor(props) {
super(props);
@@ -21,7 +22,12 @@ export default class extends Component {
createColumnDefs() {
return [
{headerName: "Make", field: "make", floatingFilterComponentFramework: FloatingFilter, filter:'set'},
{
headerName: "Make",
field: "make",
floatingFilterComponentFramework: FloatingFilter,
filter: 'set'
},
{headerName: "Model", field: "model"},
{headerName: "Price", field: "price"}
];
@@ -36,14 +42,17 @@ export default class extends Component {
}
render() {
let containerStyle = {
height: 115,
width: 500
let divStyle = {
height: 400,
width: 945
};
// combine the styles
const style = Object.assign({}, divStyle, overrideStyle);
return (
<div style={containerStyle} className="ag-fresh">
<h1>Simple ag-Grid React Example</h1>
<div style={style} className="ag-fresh">
<h1>Floating Filter Example</h1>
<AgGridReact
// properties
columnDefs={this.state.columnDefs}

View File

@@ -0,0 +1,3 @@
.ag-floating-filter-button button {
margin: 0
}

View File

@@ -1,35 +1,35 @@
import React, {Component} from "react";
import ReactDOM from "react-dom";
export default class FloatingFilter extends Component {
constructor(props) {
super();
super(props);
this.state = {
parentModel: null
}
}
onParentModelChanged(parentModel){
this.setState ({
// when does this get called? how to test this?
onParentModelChanged(parentModel) {
this.setState({
parentModel: parentModel
})
}
remove(item){
remove(item) {
this.props.onFloatingFilterChanged({
model:this.state.parentModel.filter(it=>it != item)
model: this.state.parentModel.filter(it => it !== item)
});
}
render() {
if (!this.state.parentModel) return null;
let that = this;
let options = this.state.parentModel.map ((item, i)=>{
let that = this;
let removeMeListener = ()=>{
// as the backing filter is a set filter what we're doing here is rendering the list in the set
// and when the [x] removing the selected item, thereby effectively hiding it
let options = this.state.parentModel.map((item, i) => {
let removeMeListener = () => {
this.remove(item)
}
};
let removeMeElement = <a onClick={removeMeListener}>[x]</a>;
return <span key={i}>{item}{removeMeElement}</span>;
});

View File

@@ -18,34 +18,29 @@
}
.customHeaderMenuButton {
margin-top: 5px;
margin-left: 4px;
float: left;
}
.customHeaderLabel {
margin-left: 5px;
margin-top: 3px;
float: left;
}
.customSortDownLabel {
float: left;
margin-left: 10px;
margin-top: 5px;
}
.customSortUpLabel {
float: left;
margin-left: 3px;
margin-top: 4px;
}
.customSortRemoveLabel {
float: left;
font-size: 11px;
margin-left: 3px;
margin-top: 6px;
}
.active {
@@ -58,13 +53,11 @@
.customHeaderLabel {
margin-left: 5px;
margin-top: 3px;
float: left;
}
.customExpandButton {
float: right;
margin-top: 5px;
margin-left: 3px;
}
@@ -120,4 +113,4 @@
<body>
<div id="app"></div>
</body>
</html>
</html>

View File

@@ -9,6 +9,10 @@ import "../node_modules/bootstrap/dist/css/bootstrap.css";
import App from "./App";
// only required when using enterprise features
// import {LicenseManager} from "ag-grid-enterprise/main";
// LicenseManager.setLicenseKey("<your license key>");
document.addEventListener('DOMContentLoaded', () => {
render(
<App/>,

View File

@@ -3,7 +3,7 @@ import React, {Component} from "react";
import {AgGridReact} from "ag-grid-react";
import StyledRenderer from "./StyledRenderer";
export default class FloatingRowComponentExample extends Component {
export default class PinnedRowComponentExample extends Component {
constructor(props) {
super(props);
@@ -33,8 +33,8 @@ export default class FloatingRowComponentExample extends Component {
headerName: "Row",
field: "row",
width: 400,
floatingCellRendererFramework: StyledRenderer,
floatingCellRendererParams: {
pinnedRowCellRendererFramework: StyledRenderer,
pinnedRowCellRendererParams: {
style: {'fontWeight': 'bold'}
}
},
@@ -42,8 +42,8 @@ export default class FloatingRowComponentExample extends Component {
headerName: "Number",
field: "number",
width: 399,
floatingCellRendererFramework: StyledRenderer,
floatingCellRendererParams: {
pinnedRowCellRendererFramework: StyledRenderer,
pinnedRowCellRendererParams: {
style: {'fontStyle': 'italic'}
}
},
@@ -55,7 +55,7 @@ export default class FloatingRowComponentExample extends Component {
for (let i = 0; i < 15; i++) {
rowData.push({
row: "Rou " + i,
row: "Row " + i,
number: Math.round(Math.random() * 100)
});
}

View File

@@ -9,46 +9,85 @@ import HeaderGroupComponent from './HeaderGroupComponent.jsx';
export default class ColDefFactory {
createColDefs() {
var columnDefs = [
{headerName: '#', width: 30, checkboxSelection: true, suppressSorting: true,
suppressMenu: true, pinned: true},
return [
{
headerName: '#',
width: 30,
checkboxSelection: true,
suppressSorting: true,
suppressMenu: true,
pinned: true,
icons: {
checkboxChecked: '<i class="fa fa-arrow-left"/>',
checkboxUnchecked: '<i class="fa fa-arrow-right"/>',
checkboxIndeterminate: '<i class="fa fa-arrow-up"/>'
}
},
{
headerName: 'Employee',
headerGroupComponentFramework: HeaderGroupComponent,
children: [
{
headerName: "Name", field: "name", enableRowGroup: true, enablePivot: true,
width: 150, pinned: true, editable: true,
headerName: "Name",
field: "name",
enableRowGroup: true,
enablePivot: true,
width: 150,
pinned: true,
editable: true,
// use a React cellEditor
cellEditorFramework: NameCellEditor
}, {
headerName: "Country", field: "country", width: 150, enableRowGroup: true, enablePivot: true,
headerName: "Country",
field: "country",
width: 150,
enableRowGroup: true,
enablePivot: true,
// an example of using a non-React cell renderer
cellRenderer: countryCellRenderer, pinned: true,
cellRenderer: countryCellRenderer,
pinned: true,
filterParams: {
cellRenderer: countryCellRenderer, cellHeight: 20
}, columnGroupShow: 'open'
cellRenderer: countryCellRenderer,
cellHeight: 20
},
columnGroupShow: 'open'
}, {
headerName: "DOB", field: "dob", width: 110, enableRowGroup: true, enablePivot: true, filter:'date',
pinned: true, cellRenderer: function(params) {
return pad(params.value.getDate(), 2) + '/' +
pad(params.value.getMonth() + 1, 2)+ '/' +
params.value.getFullYear();
}, columnGroupShow: 'open'
headerName: "DOB",
field: "dob",
width: 110,
enableRowGroup: true,
enablePivot: true,
filter: 'date',
pinned: true,
cellRenderer: function (params) {
return pad(params.value.getDate(), 2) + '/' +
pad(params.value.getMonth() + 1, 2) + '/' +
params.value.getFullYear();
},
columnGroupShow: 'open'
}
]
},
{
headerName: 'IT Skills',
children: [
{headerName: "Skills", width: 125, suppressSorting: true, field: 'skills', enableRowGroup: true, enablePivot: true,
{
headerName: "Skills",
width: 125,
suppressSorting: true,
field: 'skills',
enableRowGroup: true,
enablePivot: true,
// supply a React component
cellRendererFramework: SkillsCellRenderer,
// supply a React component
filterFramework: SkillsFilter
},
{headerName: "Proficiency", field: "proficiency", width: 135, enableValue: true,
{
headerName: "Proficiency",
field: "proficiency",
width: 135,
enableValue: true,
// supply a React component
cellRendererFramework: ProficiencyCellRenderer,
// supply a React component
@@ -65,7 +104,6 @@ export default class ColDefFactory {
]
}
];
return columnDefs;
}
}
@@ -73,7 +111,7 @@ export default class ColDefFactory {
// need to use React for it.
function countryCellRenderer(params) {
if (params.value) {
var flag = "<img border='0' width='15' height='10' " +
const flag = "<img border='0' width='15' height='10' " +
"style='margin-bottom: 2px' src='http://flags.fmcdn.net/data/flags/mini/"
+ RefData.COUNTRY_CODES[params.value] + ".png'>";
return flag + " " + params.value;

View File

@@ -76,10 +76,6 @@ export default class RichGridExample extends Component {
this.columnApi = params.columnApi;
}
selectAll() {
this.api.selectAll();
}
deselectAll() {
this.api.deselectAll();
}
@@ -156,7 +152,8 @@ export default class RichGridExample extends Component {
<div style={{padding: 4}} className={'toolbar'}>
<span>
Grid API:
<button onClick={this.selectAll.bind(this)}>Select All</button>
{/* use ref to access the api in selectAll */}
<button onClick={() => { this.refs.myGrid.api.selectAll() }}>Select All</button>
<button onClick={this.deselectAll.bind(this)}>Clear Selection</button>
</span>
<span style={{marginLeft: 20}}>
@@ -186,6 +183,7 @@ export default class RichGridExample extends Component {
gridTemplate = (
<div style={{height: 400, width: 945}} className="ag-fresh">
<AgGridReact
ref="myGrid"
// gridOptions is optional - it's possible to provide
// all values as React props
gridOptions={this.gridOptions}

View File

@@ -7,7 +7,8 @@ export default class SortableHeaderComponent extends React.Component {
constructor(props) {
super(props);
this.props.column.addEventListener('sortChanged', this.onSortChanged.bind(this));
// 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 ''
@@ -16,6 +17,9 @@ export default class SortableHeaderComponent extends React.Component {
}
}
componentWillUnmount() {
this.props.column.removeEventListener('sortChanged', this.onSortChanged);
}
render() {
let sortElements = [];
@@ -51,7 +55,7 @@ export default class SortableHeaderComponent extends React.Component {
this.props.setSort(order, event.shiftKey);
};
onSortChanged() {
onSortChanged = () => {
if (this.props.column.isSortAscending()) {
this.setState({
sorted: 'asc'