Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Adjust widget height via javascript in DNG

 I have declared the widget height in the xml-file: 

<ModulePrefs title="Formal Review" height="300" scrolling='true'>

Now I want to adjust the widget height according to the height of the table via the
javascript file. I can get the table height and the widget height:
 let tableHeight = tableElement.offsetHeight
    console.log (tableHeight) // answer (e.g.) 412
    console.log (window.innerHeight) // answer 300

But all trials to change the widget height does not work. I have tried something like:
window.reSize(200,500)
window.style.height = 500

I am looking forward to any help.

0 votes


Accepted answer

Permanent link
You need to use gadgets.window.adjustHeight()

Use with no argument to auto size, or use with an argument to set a specific height, eg. gadgets.window.adjustHeight(200);
Antje Rößle-Tuchel selected this answer as the correct answer

1 vote

Comments

thank you for the hint: but if I do so, I get the error message: Cannnot read properties of undefined (reading "adjustHeight"). 

OK I've just checked my widget.xml file and I have the following declared for the module

    <ModulePrefs title="FMEA Assistant" height="680">
        <Optional feature="com.ibm.rdm.rm.api"/>
        <Require feature="dynamic-height"/>
    </ModulePrefs>

See if adding the dynamic-height feature makes the gadget work. 

The other issue may be that the code is being called before the objects have been initialised. I have the gadget function calls inside an event listener hooked to 'DOMContentLoaded'

2 votes

 Thank you very much. The require feature in the xml-file was missing. Now it works!

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,930

Question asked: Mar 04, 2:43 a.m.

Question was seen: 360 times

Last updated: Mar 05, 8:01 a.m.

Confirmation Cancel Confirm