-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2ee64e
commit 08ca938
Showing
1 changed file
with
15 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,22 @@ | ||
import React, { Component } from 'react'; | ||
|
||
// Wrapper componenet used when having an editor which is a redux container. | ||
// Wrapper HOC used when having an editor which is a redux container. | ||
// Required since react-data-grid requires access to getInputNode, getValue, | ||
// howvever when doing this.getEditor() in react-data-grid we get a react | ||
// componenet wrapped by the redux connect function and thus wont have access | ||
// to the required methods. | ||
export class ContainerEditorWrapper extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.setEditorRef = this.setEditorRef.bind(this); | ||
} | ||
|
||
getInputNode() { | ||
return this.editorRef.getInputNode(); | ||
} | ||
|
||
getValue() { | ||
return this.editorRef.getValue(); | ||
} | ||
|
||
setEditorRef(ref) { | ||
this.editorRef = ref; | ||
} | ||
|
||
render() { | ||
let EditorComponent = this.props.editorComponent; | ||
return (<EditorComponent refCallback={this.setEditorRef} {...this.props} />); | ||
} | ||
} | ||
|
||
ContainerEditorWrapper.propTypes = { | ||
value: React.PropTypes.string.isRequired, | ||
column: React.PropTypes.object.isRequired, | ||
rowData: React.PropTypes.isRequired, | ||
editorComponent: React.PropTypes.object.isRequired | ||
export default (ContainerEditor) => { | ||
return class ContainerEditorWrapper extends Component { | ||
getInputNode() { | ||
return this.editorRef.getInputNode(); | ||
} | ||
|
||
getValue() { | ||
return this.editorRef.getValue(); | ||
} | ||
|
||
render() { | ||
return (<ContainerEditor refCallback={(ref) => { this.editorRef = ref; }} {...this.props} />); | ||
} | ||
}; | ||
}; | ||
|
||
export default ContainerEditorWrapper; |