Skip to Content
author's profile photo Former Member
Former Member

Cockpit NG: How to set the height of a Widget Template?

Hi folks,

this is likely an easy question. But nevertheless, my Widget Template always opens with the size 600px x 400px. And I don't know how to change the height.

Best regards, Clemens

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2015 at 08:58 AM

    You can set the size also in the view.zul file:

     <widget xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.zkoss.org/2005/zul">
         <style src="${wr}/default.css"/>
         <div style="height:400px;">
     ....
         </div>
     </widget>
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2015 at 08:47 AM

    I found a solution. But obviously not a smart one.

     @Override
     public void initialize(final Component comp) {
         super.initialize(comp);
     
         Window window = findAncestorWindow(comp);
         if (window != null) {
             window.setHeight("700px");
         }
     }
     private static Window findAncestorWindow(Component component) {
         Component current = component;
         while (current != null && !(current instanceof Window) && !(current instanceof Widget)) {
             current = current.getParent();
         }
         return current instanceof Window ? (Window) current : null;
     }
    
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.