Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1166

Cannot set listbox selection in event-handler after manual selection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • None
    • 6.0.0, 6.0.1
    • None

      For example, given a zul page with a listbox and a button:

      <button label="Init" forward="mainWin.onInitList" />
      <listbox id="exampleList" mold="select" rows="1"></listbox>

      The event-handler onInitList is as follows:

      public void onInitList()
      {
      Listbox example_list = (Listbox) getFellow("exampleList");
      example_list.getItems().clear();
      for (int i = 0; i < 7; i++)

      { example_list.appendItem("Item " + i, "" + i); // put numbers in listbox as an example }

      example_list.setSelectedIndex(6); // select last item
      }

      When user clicks on the button, then the listbox will be filled with 7 items and the last item will be selected.
      So far everything is okay. However, if user now manually selects another list item (e.g. "Item 2") and then presses the button again, then suddenly no list item is selected (although the last item should be selected again).

      A workaround is to call example_list.invalidate() after example_list.setSelectedIndex(6).

            Unassigned Unassigned
            mpaula mpaula
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: