Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
AgGridReact open table in new window

I’m trying to use React’s new Portal function in order to open an AgGridReact component in a pop up window. However, the issue I am running into is when I open the component in a new window, the table functions do not work while the mouse cursor is in the pop up window. However, if I drag my mouse into the original window, the component starts to work, allowing me to change the size of the columns while my mouse is above the original window and not the pop up window.

Specifically, I am creating a new html, then calling

ReactDOM.createPortal(this.props.children, this.containerEl)
(


containerEl

being the created html element). I then attach the new element to the created external window. I then pass

containerEl

as the

popupParent

to the AgGridReact component. If anyone would like to see anymore code I can post as required. But any help or pointers would be greatly appreciated.

Where the AgGridReact is rendered

    const [openedElement, setOpenedElement] = useState()
   
    const updateOpenedElement = val => {
   
      !openedElement && setOpenedElement(val)
  
    } 

    <AgGridReact 
   
    ...
  
     popupParent={openedElement? openedElement: window.document.getElementById("root")}

    ...
    
    >
    </AgGridReact>)

​ And the code for the NewWindow is as follows

    const copyStyles = (sourceDoc, targetDoc) => {...}
    ​
    class NewWindow extends React.Component {
      constructor(props) {
        super(props)
        this.setOpenedElement = props.setOpenedElement
        this.containerEl = document.createElement('div')
        this.externalWindow = null

      }

      render() {
        this.setOpenedElement(this.containerEl)
        return ReactDOM.createPortal(this.props.children, this.containerEl)

      }

      componentDidMount() {

        this.externalWindow = window.open("", "", 
        "width=600, height=400, left=200, top=200")
 
        copyStyles(document, this.externalWindow.document)

        this.externalWindow.document.body.appendChild(this.containerEl)
 
      }
   ​
  
      componentWillUnmount() {
  
        this.externalWindow.close()

      }
    }

​ setOpenedElement is called in a parent component, which I am using in order to create the element popupParent will use.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!