【问题标题】:How can we enable a disabled item in a listbox in gwt?我们如何在 gwt 的列表框中启用禁用的项目?
【发布时间】:2014-03-25 10:03:45
【问题描述】:

要禁用列表框中的项目,我使用给定的代码。

((Element) list.getElement().getChild(index).getChild(index)).setAttribute("disabled","disabled");

但我需要再次启用该项目。有什么解决方案。请帮我解决问题。

提前谢谢你。

【问题讨论】:

    标签: gwt listbox


    【解决方案1】:

    我猜“removeAttribute”会起作用:

    ((Element) list.getElement().getChild(index).getChild(index)).removeAttribute("disabled");
    

    【讨论】:

      【解决方案2】:

      试一试

      使用“GWT JSNI”(禁用第 0 个选项)

          final ListBox lb = new ListBox(); 
          lb.addItem("foo");
          lb.addItem("bar");
          lb.addItem("baz");
          lb.addItem("toto");
          lb.addItem("tintin");
          disableSelectOption(lb.getElement(), 0);
      
      ...
      
      public static native void disableSelectOption(Element listElement, int index) /*-{
          listElement.options[index].disabled = true;
      }-*/;
      

      使用setAttribute(禁用第0个选项)

          ((Element)lb.getElement().getChild(0)).setAttribute("disabled", "");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-09
        • 1970-01-01
        相关资源
        最近更新 更多