Announcement

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

    Display Icon in Grid corresponding to DataSourceEnumField

    Hello,

    I have a TreeGrid. The leaves in the TreeGrid column should display a certain image next to it (not in an extra column), depending on an enum value. What is the best way to achieve this?

    I have read about DataSourceEnumField and that you can map images to enum values. But I think I cannot use this approach since I don't want a seperate column for the image. The image should be displayed next to the node title, just like so: http://www.smartclient.com/smartgwt/...nding_ondemand . So far, I can only achieve this by setting the "icon" attribute of a list grid record.

    I could extend ListGridRecord and add an extra enum field, then query this field in a CellFormatter and set the icon attribute accordingly. But maybe there is an easier approach?

    #2
    See the valueIcons feature (in ListGrid, TreeGrid's superclass).

    Comment


      #3
      Hello Isomorphic,

      I've read about the setValueIcons feature. But I need to display the icon next to the node text, not in a seperate column. I want it to look like this:

      http://www.smartclient.com/smartgwt/...nding_ondemand

      When I use setValueIcons() on my node text field, nothing happens, which is no surprise since the node text field does not contain an enum value.

      As far as I understand, I can only set the value icons for an extra list field containing the enum value. But I need both the icon and the node text in one column. Is this possible?

      I now have:

      Code:
          TreeGridField titleField = new TreeGridField( "beschreibung", "Beschreibung" );
          titleField.setType( ListGridFieldType.TEXT );
      
          TreeGridField iconField = new TreeGridField( "status", "Status" );
          iconField.setType( ListGridFieldType.IMAGE );
      
          Map<String, String> iconMap = new HashMap<String, String>();
          iconMap.put( "IDLE", "startbuchung.png" );
          iconMap.put( "RUNNING", "endbuchung.png" );
      
          iconField.setValueIcons(iconMap);
      But what I need is the following:

      Code:
          TreeGridField titleField = new TreeGridField( "beschreibung", "Beschreibung" );
          titleField.setType( ListGridFieldType.TEXT );
      
          Map<String, String> iconMap = new HashMap<String, String>();
          iconMap.put( "IDLE", "startbuchung.png" );
          iconMap.put( "RUNNING", "endbuchung.png" );
      
          titleField.setValueIcons(iconMap);
      Which is obviously not possible since the title field does not know of the enum values in the enum DataSource field.
      Last edited by jballh; 14 Jul 2009, 00:44.

      Comment

      Working...
      X