Skip to content

Commit

Permalink
fixed checkbox offset
Browse files Browse the repository at this point in the history
  • Loading branch information
ViciEnzo committed Feb 6, 2017
1 parent efa7a87 commit 2f0af0c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const React = require('react');
const { Editors, Toolbar, Formatters } = require('react-data-grid-addons');
const { AutoComplete: AutoCompleteEditor, DropDownEditor } = Editors;
const { ImageFormatter } = Formatters;
const { Menu: { ContextMenu, MenuItem, SubMenu } } = require('react-data-grid-addons');

faker.locale = 'en_GB';

Expand Down Expand Up @@ -246,6 +247,7 @@ const Example = React.createClass({
<ReactDataGrid
ref="grid"
enableCellSelect={true}
contextMenu={<MyContextMenu onRowDelete={this.deleteRow} onRowInsertAbove={this.insertRowAbove} onRowInsertBelow={this.insertRowBelow} />}
columns={this.getColumns()}
rowGetter={this.getRowAt}
rowsCount={this.getSize()}
Expand All @@ -258,6 +260,50 @@ const Example = React.createClass({
}
});


// Create the context menu.
// Use this.props.rowIdx and this.props.idx to get the row/column where the menu is shown.
const MyContextMenu = React.createClass({
propTypes: {
onRowDelete: React.PropTypes.func.isRequired,
onRowInsertAbove: React.PropTypes.func.isRequired,
onRowInsertBelow: React.PropTypes.func.isRequired,
rowIdx: React.PropTypes.string.isRequired,
idx: React.PropTypes.string.isRequired
},

onRowDelete(e, data) {
if (typeof(this.props.onRowDelete) === 'function') {
this.props.onRowDelete(e, data);
}
},

onRowInsertAbove(e, data) {
if (typeof(this.props.onRowInsertAbove) === 'function') {
this.props.onRowInsertAbove(e, data);
}
},

onRowInsertBelow(e, data) {
if (typeof(this.props.onRowInsertBelow) === 'function') {
this.props.onRowInsertBelow(e, data);
}
},

render() {
return (
<ContextMenu>
<MenuItem data={{rowIdx: this.props.rowIdx, idx: this.props.idx}} onClick={this.onRowDelete}>Delete Row</MenuItem>
<SubMenu title="Insert Row">
<MenuItem data={{rowIdx: this.props.rowIdx, idx: this.props.idx}} onClick={this.onRowInsertAbove}>Above</MenuItem>
<MenuItem data={{rowIdx: this.props.rowIdx, idx: this.props.idx}} onClick={this.onRowInsertBelow}>Below</MenuItem>
</SubMenu>
</ContextMenu>
);
}
});


module.exports = exampleWrapper({
WrappedComponent: Example,
exampleName: 'All the features grid',
Expand Down
2 changes: 1 addition & 1 deletion themes/react-data-grid-checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
padding: 0px 10px;
}
.react-grid-HeaderCell > .react-grid-checkbox-container > .react-grid-checkbox-label {
margin : 0;
/*margin : 0;*/
}
.radio-custom + .radio-custom-label:before {
border-radius: 50%;
Expand Down

0 comments on commit 2f0af0c

Please sign in to comment.