admin管理员组

文章数量:1401630

Now I've using ag-Grid that can create custom renderer for each data cells but it's required Html elements

For example they're an Elements that can be created by calling document.createElement()

But I want to use React element as custom renderer for my convenient

Don't sure that I can do that or not ?

Now I've using ag-Grid that can create custom renderer for each data cells but it's required Html elements

For example they're an Elements that can be created by calling document.createElement()

But I want to use React element as custom renderer for my convenient

Don't sure that I can do that or not ?

Share Improve this question asked Jul 6, 2016 at 10:19 Ittipon TeerapruettikulchaiIttipon Teerapruettikulchai 4755 silver badges22 bronze badges 2
  • 1 So if I got it right, you are creating a custom cell renderer like this: cellRenderer: reactCellRendererFactory(MyCustomCellRenderer), right? And your question is if you can use React ponents in the jsx that the render method of MyCustomCellRenderer ponent returns? – Smilev Commented Jul 6, 2016 at 13:55
  • @Smilev, that is exactly what I'd like to know. At the very least, it seems that cannot be done in the function version of a cell renderer, Can that be done in the ponent form of the cellRenderer? – dsh Commented Aug 28, 2016 at 6:08
Add a ment  | 

2 Answers 2

Reset to default 2

You can try to use getDOMNode for example: this.refs.giraffe.getDOMNode(), or:

import ReactDOM from 'react-dom';
...
const submitBtn = ReactDOM.findDOMNode(this.refs.submitButton)

But that way has some deprecation issues, more here: React.js: The difference between findDOMNode and getDOMNode

There's a new React way in ag-grid for this purpose. It's quite recent so you have to update your ag-grid module. Instead of using cellRenderer use cellRendererFactory to which you can pass React ponent directly. Source: https://www.ag-grid./javascript-grid-cell-rendering-ponents/#react-cell-rendering

本文标签: javascriptHow can I convert React Element to Html elementStack Overflow