cancel
Showing results for 
Search instead for 
Did you mean: 

Changeable image using table view iterator

Former Member
0 Kudos

Hello Forum -

I have a tableview iterator working using cl_htmlb_image class. The icon shows up perfectly based on the column value (X=green; space=red). I would now like to click on the icon (just like clicking on checkbox) and turn the color from red->green or green->red which should of course change the value of the column as well.

Here is my code, please help me:

======================================================

IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

======================================================

DATA: img TYPE REF TO cl_htmlb_image.

DATA: beetable TYPE REF TO cl_bsp_bee_table.

CREATE OBJECT img.

CREATE OBJECT beetable.

CASE p_column_key.

WHEN 'ACTVFLAG'.

img->id = p_cell_id.

IF c_row_ref->actvflag = 'N' OR

c_row_ref->actvflag IS INITIAL.

img->src = 'ICON_LED_RED'.

img->alt = 'Inactive'.

ELSE.

img->src = 'ICON_LED_GREEN'.

img->alt = 'Active'.

ENDIF.

beetable->add( element = img level = 1 ).

p_replacement_bee = beetable.

Thanks,

Partho

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Got it done.

Here is what I used:

IF event_id IS NOT INITIAL and

event_id->event_name = 'image' and

event_id->event_id = 'img1'.

Thanks.

Former Member
0 Kudos

Hi,

In the layout you use <htmlb:image> and onClick attrbute you will get the solution.

Regards,

Azaz Ali.

Former Member
0 Kudos

My image is generated using iterator and is one of the column in the table view. How do I intercept the image click in do_handle_event. When I click on the image and look at the event id,type etc everything is related to tableview.

Please help.

Thanks,

Former Member
0 Kudos

How do I read the image event? Do I use cl_htmlb_button class to read this event.

I tried the code below and it is giving type conflict error at runtime.

data: event_id type ref to if_htmlb_data,

image_event TYPE REF TO CL_HTMLB_button.

if event_id is not initial.

image_event ?= event_id.

if image_event->id = 'img1'.

c_msgtext = 'You have pressed the image icon'.

c_msgtype = 'OK'.

endif.

endif.

athavanraja
Active Contributor
0 Kudos

in the iterator (render cell start) when rendering the image add the onclick property to image.

p_replacement_bee = cl_htmlb_image=>factory( id = p_cell_id src = icon_plane onclick = 'image_click' )

now when the user click on the image oninputprocessing will be triggered and check whether its is image click, if yes set a variable to some value to indicate that the image is clicked (and also to identify what image is clicked)

option1: store these info as a serverside cookie and read it in your IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START method to change the image

or

option2: pass these values to iterator class attribute and read it in your IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START method to change the image.

Regards

Raja