cancel
Showing results for 
Search instead for 
Did you mean: 

Image Column in Tableview

Former Member
0 Kudos

Hi all,

here's the thing: I'm trying to add an image column to a tableview but it doesn't work (there's no error, but the image doesn't appear). I've tried it with an iterator.

Page Layout:

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design           = "design2003"
               controlRendering = "SAP" >
  <htmlb:document>
    <htmlb:documentHead>
    </htmlb:documentHead>
    <htmlb:documentBody>
      <htmlb:form>
        <htmlb:tableView id            = "tableview_scarr"
                         table         = "<%= pa_tab_scarr %>"
                         headerText    = "Table SCARR"
                         headerVisible = "TRUE"
                         iterator      = "<%= application %>" >
        </htmlb:tableView>
        <%
  IF page->messages->num_messages( ) > 0.
        %>
        Error
        <%
  ENDIF.
        %>
      </htmlb:form>
    </htmlb:documentBody>
  </htmlb:document>
</htmlb:content>

OnInitialization:

SELECT * FROM scarr INTO TABLE pa_tab_scarr.

My application class is my iterator. It implements GET_COLUMN_DEFINITIONS:

METHOD if_htmlb_tableview_iterator~get_column_definitions.
  DATA tv_column TYPE tableviewcontrol.

  tv_column-columnname          = 'SHOW_ICON'.
  tv_column-title               = 'SHOW_ICON'.
  tv_column-encode = 'X'.
  tv_column-width               = '100'.
  APPEND tv_column TO p_column_definitions.

  CLEAR tv_column.
  tv_column-columnname          = 'CARRID'.
  tv_column-width               = '100'.
  APPEND tv_column TO p_column_definitions.

ENDMETHOD.

...and it implements RENDER_CELL_START:

METHOD if_htmlb_tableview_iterator~render_cell_start.
  CASE p_column_key.
    WHEN 'SHOW_ICON'.
      DATA col_image TYPE REF TO cl_htmlb_image.
      CREATE OBJECT col_image.
      col_image->src = "@2N@".
      col_image->width = '16'.
      col_image->height = '14'.

      p_replacement_bee = col_image.
  ENDCASE.
ENDMETHOD.

I've checked the SICF, but all services concerning icons are activated. This is my first Iterator so i'm not sure if i've forgotten something. Why the image is not shown?

Regards

Mark-André

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

DATA: icon_plane TYPE string.

icon_plane = cl_bsp_mimes=>sap_icon( id = 'ICON_WS_PLANE' ).
and now icon_pane to src property fo the image

DATA col_image TYPE REF TO cl_htmlb_image.

CREATE OBJECT col_image.

col_image->src = icon_plane .

col_image->width = '16'.

col_image->height = '14'.

Former Member
0 Kudos

Hi Durairaj Athavan Raja,

your solution works.

Thank you!

athavanraja
Active Contributor
0 Kudos

Glad to know that.

But the point made by Tatvagna is a valid one. you should try and avoid using key words as variable names.

Former Member
0 Kudos

I know that "application" is a key word for my application class. That is also my iterator because my application class implements the interface IF_HTMLB_TABLEVIEW. So this was my intent and no accident.

Regards

Mark-André

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Mark,

First of all, define an object named iterator in page attributes type ref to iterator_class_name

i.e

iterator TYPE REF TO ZCL_ITERATOR(or iterator_class_name)

Then in <b>onInitialization</b> use

create object iterator.

Also you can use any name of the iterator object...but the name application is reserved for the application class....

So your tableView code will be

        <htmlb:tableView id            = "tableview_scarr"
                         table         = "<%= pa_tab_scarr %>"
                         headerText    = "Table SCARR"
                         headerVisible = "TRUE"
                         iterator      = "<%= iterator %>" >

Rest all is fine...!!

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.