문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top