Please note that you cannot draw an element that has a "display: none" or "visibility: hidden" property, since the DOM element of the Grid must be appended to the document and fully rendered.
Therefore, you could wrap the Grid in a container and export the visible part of the component with the exportImage method of the drawing API: