JavaScript node not resized in WebPortal

Dear all,

I have received a legacy node that plots a chart in Webportal. The chart looks great but the users need to scroll down to see the whole chart. I believed the next lines try to address but they do not work somehow.

// Auto resize view when shown in WebPortal
if (parent != undefined && parent.KnimePageLoader != undefined) {
	parent.KnimePageLoader.autoResize(window.frameElement.id);
}

I also tried to research about the KnimePageLoader. I would appreciate any reference to this too.

Thanks in advance,

Miguel

Hi,

unfortunately there is no public documentation available about the development of JavaScript based nodes. This is mainly due to the fact, that the API is not considered stable yet and the behavior, in your case resizing, will improve or change in the future.

That being said, I can give you a few pointers towards the issue. The code you call is already correct. It needs to be called at the end of the layout process, as to resize the encapsulating iframe. The autoResize function looks for the first element inside the body tag and takes this component's dimensions as the size hint. If your view contains of several top level elements and the first one does not appropriately reflect the size of the view the easiest fix is to encapsulate all components in a wrapping tag (e.g. div).

Another possibility is to supply the autoResize method with a specific width and height argument. This can be applied when a fixed size is desired and known before runtime. The appropriate code block could look like this:

// Auto resize view when shown in WebPortal
if (parent != undefined && parent.KnimePageLoader != undefined) {
    parent.KnimePageLoader.autoResize(window.frameElement.id, 800, 600);
}

If your view changes size during it's lifetime and you need to adjust the iframe on certain events, you can also call the autoResize method after every size change.

 

Please note that we are currently working on making this procedure automatic without the need to specifically call resize methods.