Announcement

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

    ListGridField setValueIcons shows up second icon

    Using 3.0

    and

    ListGridField myField= new ListGridField("myField");
    myField.setType(ListGridFieldType.IMAGE);
    myField.setValueIcons(new HashMap<String, String>(){{
    put("false", "img1.png");
    put("true", "img2.png");
    }});

    ...
    new ListGrid().setFields(myField);
    ...
    where record is myField false or true

    Will display the correct icons, but additionaly a second icon with src false.
    Doing myField.put("anotherValue", "img3.png");
    Will display 2 icons again.

    Can you tell me the reason, please?

    Thanks

    #2
    The behavior you're seeing appears to be a result of combining fieldType being set to ListGridFieldType.IMAGE with valueIcons.

    ListGridField.valueIcons are used to display standard images for various field values. By default the 'value' of the field is displayed next to the icon (though this can be suppressed by setting showValueIconsOnly).

    ListGridFieldType.IMAGE is used for displaying images. The cell value is used as the URL for the image (potentially with a custom prefix / suffix).

    If you have both specified you see 2 images -- the valueIcon for the value followed by the image with URL derived directly from the value.
    it sounds like you want to just use valueIcons and not show any other value next to them. To achieve this, remove the call to setType(...) and instead call setShowValueIconOnly().

    Regards
    Isomorphic Software.

    Comment


      #3
      Thanks for fast answer, helps !

      Comment


        #4
        What I need is a icon shown next to the value,
        like setValueIcons, but the value should always be used as the url of the image,
        so no map is actually needed for definition.

        It's like the Image field type is working, but it seems like it's not supported for icons.

        Can you provide a solution ?

        Comment


          #5
          You could override ListGrid.getValueIcon() to give you this behavior - simply take the cell value and apply the appropriate value icon prefix and suffix and return it.

          Comment


            #6
            I noticed ListGridField has a

            setValueIcons(Map)

            But is there a way to get a field's valueIcons map?

            There doesn't seem to be an exposed getter and I tried to just guess and do:

            field.getAttributeAsMap("valueIcons") but that returns null.

            Thanks!

            Comment

            Working...
            X