在 Zkoss 中选中的复选框设置为禁用(真),但我希望复选框和勾选的可见性保持不变

In Zkoss selected checkbox is setDisabled(true) but i want visibility of checkbox and tick remain same

本文关键字:复选框 我希望 可见性 设置 Zkoss      更新时间:2024-06-11
for(int i=0;i<list_id.size();i++)
            {
                count++;
                Listitem l1=new Listitem();
                org.zkoss.zul.Checkbox ccc=new org.zkoss.zul.Checkbox();
                l1.setParent(signlist);
                Listcell c1=new Listcell();
                Listcell c2=new Listcell();
                Listcell c3=new Listcell();
                c1.setParent(l1);
                c2.setParent(l1);
                c3.setParent(l1);
                c2.setLabel(""+count);
                c3.setLabel(getSignId(list_id.get(i),temp)); 
                ccc.setParent(c1);              
                ccc.setId(list_id.get(i)+":"+i+group_id);
                InputStream in =rs.getAsciiStream(2);
                StringWriter w = new StringWriter();
                IOUtils.copy(in, w);
                mapped_sign = w.toString();
                if(mapped_sign.contains("|"))
                {
                    list_Name=mapped_sign.split("''|");
                    for(int k=0;k<list_Name.length;k++)
                    {
                        list_id_Check.add(list_Name[k]);
                    }
                    if(list_id_Check.contains(list_id.get(i)))
                    {
                        ccc.setChecked(true);
                    }
                }
                else
                {
                    if(list_id.get(i).equals(mapped_sign))
                    {
                        ccc.setChecked(true);
                    }
                }
                ccc.setDisabled(true);
            c3.setId(list_id.get(i)+":"+group_id);  
            }

当我应用设置禁用(true(时,选中和未显示的复选框可见性会消失。 我只想在应用set禁用复选框和勾选的可见性仍然保持不变。

据我所知,没有特定于 ZK 的方法可以做到这一点。
不过,您可以使用普通的CSS(也许还有自定义复选框精灵(来设置自己的复选框样式。

下面是一个示例(CSS取自 https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Advanced_styling_for_HTML_forms(

<zk>
  <window border="normal" title="hello">
    <style>
        :root input[type=checkbox] {
          /* original check box are push outside the viexport */
          position: absolute;
          left: -1000em;
        }
        :root input[type=checkbox] + label:before {
          content: "";
          display: inline-block;
          width  : 16px;
          height : 16px;
          margin : 0 .5em 0 0;
          background: url("https://developer.mozilla.org/files/4173/checkbox-sprite.png") no-repeat 0 0;
        /* The following is used to adjust the position of 
           the check boxes on the text baseline */
          vertical-align: bottom;
          position: relative;
          bottom: 2px;
        }
        :root input[type=checkbox]:checked + label:before {
          background-position: 0 -16px;
        }

    </style>
    <vlayout>
          <checkbox id='chk1' label='enabled' />
          <checkbox id='chk2' label='disabled unchecked' disabled='true' />
          <checkbox id='chk3' label='disabled checked' checked='true' disabled='true' />
    </vlayout>
  </window>
</zk>

当然,你不应该链接到Mozilla的精灵,而应该提供你自己的精灵。

这是一个SO答案,提供了进一步的链接和示例:如何使用CSS设置复选框样式?

相关文章: