使用 javascript 展开/折叠 zk 面板

发布于 2024-12-19 17:07:05 字数 346 浏览 1 评论 0原文

我想点击 ZK 的 borderlayout(可折叠的“东”或“北”或...)以使用 javascript 暂时打开它。 我应该怎么办?

预先感谢朋友。

更新:

关闭时,通过单击关闭的边框区域(而不是在打开的图标上)(查看光标的图中位置) 将暂时开放。我想要一个封闭的 borderLayout 并使用 javascript/jquery 打开它。

图片: 在此处输入图像描述

I wanna click on a ZK's borderlayout(collapsible "East" OR "North" OR...) to open it temporarily with javascript.
what should I do?

thanks in advance buddies.

UPDATE:

When it is closed, by clicking on the closed border area(not on the Open ICON) (Look at the cursor's position in the picture) it will be open temporarily. I want a closed borderLayout and open it like that, with javascript/jquery.

the picture:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-12-26 17:07:05

1.从ZK客户端引擎获取widget。

2.调用 setOpen(true) 或 setOpen(false)

这是一个示例,您也可以在 ZK fiddle 平台上测试它。

http://zkfiddle.org/sample/bk3jop/1 -通过-javascript关闭边框布局面板

<zk xmlns:w="client">

  <script>
    function closeNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
      widget.setOpen(false);

    }
    function openNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
      widget.setOpen(true);

    }    
  </script>
  <button label="click me to close it" w:onClick="closeNorth();" />          
  <button label="click me to open it" w:onClick="openNorth();"  />    

  <borderlayout >
    <north id="mynorth" title="North" maxsize="300" size="50%" splittable="true" collapsible="true">
          <div>
           Test .... <textbox />
          </div>
    </north>
  </borderlayout>

</zk>

1.Get the widget from ZK client engine.

2.call setOpen(true) or setOpen(false)

Here's a sample for this, and also you could test it on ZK fiddle platform.

http://zkfiddle.org/sample/bk3jop/1-Close-border-layout-panel-by-javascript

<zk xmlns:w="client">

  <script>
    function closeNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
      widget.setOpen(false);

    }
    function openNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
      widget.setOpen(true);

    }    
  </script>
  <button label="click me to close it" w:onClick="closeNorth();" />          
  <button label="click me to open it" w:onClick="openNorth();"  />    

  <borderlayout >
    <north id="mynorth" title="North" maxsize="300" size="50%" splittable="true" collapsible="true">
          <div>
           Test .... <textbox />
          </div>
    </north>
  </borderlayout>

</zk>
烟火散人牵绊 2024-12-26 17:07:05

为了您的目的,我在这里提供另一个例子。
http://zkfiddle.org/sample/bk3jop/2 -Close-border-layout-panel-by-javascript

<script>
    function openNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 

       if(!widget.isOpen()){
         try{
           widget.doClick_({
             domTarget:widget.$n('colled')  
           });
         }catch(e){ //ignore unhandled exception.
         }
       }

    }    
  </script>         

无论如何,这更像是一种黑客攻击。

更详细的你可以参考
https://github .com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/layout/LayoutRegion.js

doClick_: function (evt) {
        var target = evt.domTarget;
        switch (target) {
        case this.$n('btn'):
        case this.$n('btned'):
        case this.$n('splitbtn'):
            if (this._isSlide || zk.animating()) return;
            if (this.$n('btned') == target) {
                var s = this.$n('real').style;
                s.visibility = "hidden";
                s.display = "";
                this._syncSize(true);
                s.visibility = "";
                s.display = "none";
            }
            this.setOpen(!this._open);
            break;
        case this.$n('colled'):                 
            if (this._isSlide) return;
            this._isSlide = true;
            var real = this.$n('real'),
                s = real.style;
            s.visibility = "hidden";
            s.display = "";
            this._syncSize();
            this._original = [s.left, s.top];
            this._alignTo();
            s.zIndex = 100;

            if (this.$n('btn'))
                this.$n('btn').style.display = "none"; 
            s.visibility = "";
            s.display = "none";
            zk(real).slideDown(this, {
                anchor: this.sanchor,
                afterAnima: this.$class.afterSlideDown
            });
            break;
        }
        this.$supers('doClick_', arguments);        
    },

For your purpose ,here I provide another example for this.
http://zkfiddle.org/sample/bk3jop/2-Close-border-layout-panel-by-javascript

<script>
    function openNorth(){
      var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 

       if(!widget.isOpen()){
         try{
           widget.doClick_({
             domTarget:widget.$n('colled')  
           });
         }catch(e){ //ignore unhandled exception.
         }
       }

    }    
  </script>         

Anyway , it's more like a hack.

For more details you could reference to
https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/layout/LayoutRegion.js

doClick_: function (evt) {
        var target = evt.domTarget;
        switch (target) {
        case this.$n('btn'):
        case this.$n('btned'):
        case this.$n('splitbtn'):
            if (this._isSlide || zk.animating()) return;
            if (this.$n('btned') == target) {
                var s = this.$n('real').style;
                s.visibility = "hidden";
                s.display = "";
                this._syncSize(true);
                s.visibility = "";
                s.display = "none";
            }
            this.setOpen(!this._open);
            break;
        case this.$n('colled'):                 
            if (this._isSlide) return;
            this._isSlide = true;
            var real = this.$n('real'),
                s = real.style;
            s.visibility = "hidden";
            s.display = "";
            this._syncSize();
            this._original = [s.left, s.top];
            this._alignTo();
            s.zIndex = 100;

            if (this.$n('btn'))
                this.$n('btn').style.display = "none"; 
            s.visibility = "";
            s.display = "none";
            zk(real).slideDown(this, {
                anchor: this.sanchor,
                afterAnima: this.$class.afterSlideDown
            });
            break;
        }
        this.$supers('doClick_', arguments);        
    },
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文