Question

I am trying to embed GoodData dashboard to an iframe in my application and it works well but each tab on that dashboard has different number of reports on it and I'd like to make the iframe height dynamic based on the actual dashboard content.

Is there a way how to do it? Does GoodData somehow propagate the space needed to render the dashboard?

Thank you.

Was it helpful?

Solution

In fact there is a postMessage() sent event called 'ui.frameinfo' which you could use to detect the dashboard tab height (when using dashboard.html). It is sent every time the tab changes its height.

The following listener should print out the iframe's internal height:

window.addEventListener('message', function(e) {
    var message;
    try {
        message = JSON.parse(e.data);
    } catch (e) {
        // valid messages are JSON
        message = {};
    }
    // drop other than GoodData events
    if (!message.gdc) return;

    if (message.gdc.name === 'ui.frameinfo') {
        console.log('frame height:', message.gdc.data.height);
    }
}

Note that this is not an official feature (yet) and potentially subject to change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top