Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SelectItem has empty value

    Hi,
    We are using smartgwt version 6.1-p20200204. We have a selectItem which shows first value as empty. We populate selectItem using valueMap.
    I tried using AllowEmptyValues as false but it didn't worked.

    Thanks

    #2
    Use setValue() to establish an initial value.

    Comment


      #3
      I am using setValue() to set initial value. It shows the value as set. Still if we click to open dropdown it show first value as empty.

      Thanks

      Comment


        #4
        The property is working as documented in a brief test. Perhaps you tried to set “allowEmptyValues” instead of the actual property name “allowEmptyValue” (no “S” at the end).

        Comment


          #5
          Hi,
          I used the "allowEmptyValue" field of SelectItem, I don't see any “allowEmptyValues” api.

          Thanks

          Comment


            #6
            Good. So, if you modify any of our samples - for instance “Various Controls” - to add the allowEmptyValue property, then you will see it functioning as documented.

            If you can show us a minimal, ready-to-run sample where the property is not behaving as documented, we would love to see it and correct any such bug as soon as possible.

            Comment


              #7
              Actually,
              We have a requirement to change select items value every 5 minutes. So, every five minutes i am changing value via setValue() and thats when its creating problems and shows first value in dropdown as empty. From initial load to first change in its value , the dropdown looks fine, but after first setValue() it looks bad with first value empty.

              Tell me if this clears things, other wise i will share a use case.

              Thanks

              Comment


                #8
                Unless you are calling setValue() with an empty value, this still does not create a problem, so we will need a minimal, ready-to-run test case that reproduces the claimed issue.

                Comment


                  #9
                  Hi,
                  Please find the ready to run use case:

                  //SelectItem creation
                  private SelectItem brandSelectItem = new SelectItem("BrandsName","BrandsTitle");

                  LinkedHashMap<String, String> valueMap = new LinkedHashMap<>();
                  valueMap.put("01", "ABrand");
                  valueMap.put("02", "BBrand");
                  valueMap.put("03", "CBrand");

                  brandSelectItem.setSortField(MYAssaAbloyConstants.VALUE);
                  brandSelectItem.setValueMap(valueMap);
                  brandSelectItem.setValueField(MYAssaAbloyConstants.BRANDFILTER_ID);
                  brandSelectItem.setDisplayField(MYAssaAbloyConstants.VALUE);

                  //And there is a timer that changes its value every 2 minutes
                  Timer brandChangeTimer = new Timer() {

                  Collection<String> values = (Collection<String>) brandSelectItem.getAttributeAsMap("valueMap")
                  .values();
                  final Queue<String> brandQueue = new LinkedList<>();
                  brandQueue.addAll(values);

                  @Override
                  public void run() {
                  String brand = StringUtils.EMPTY;
                  if (null != brandQueue.peek()) {
                  brand = brandQueue.poll();
                  brandSelectItem.setValue(brand);
                  }
                  brandQueue.add(brand);
                  }
                  };
                  brandChangeTimer.scheduleRepeating(120000);

                  Thanks

                  Comment

                  Working...
                  X