cancel
Showing results for 
Search instead for 
Did you mean: 

image with onClientClick in tableview leads to JavaScript Error?

daniel_humberg
Contributor
0 Kudos

Have you ever tried to add an htmlb:image to a htmlb:tableView using an iterator?

I just did that and it workek fine until I added a onClientClick to the image. Then, when I open the page, I get a JavaScrip-Error "Syntax Error". After one of these errors per line, the page and the onClientClick works perfectly.

Is it a error in the framework or am I doing something wrong. this is my code (a bit complicated, hope you understand it)


METHOD if_htmlb_tableview_iterator~render_cell_start .

  DATA lorv_image TYPE REF TO cl_htmlb_image.
  DATA lorv_link    TYPE REF TO cl_htmlb_link.
  DATA lorv_bee_table TYPE REF TO cl_bsp_bee_table.
  DATA lv_msg_id  TYPE string.

  FIELD-SYMBOLS: <fs_row> TYPE itsm_webstruc.
  ASSIGN p_row_data_ref->* TO <fs_row>.

  CASE p_column_key.
    WHEN 'MNUMM_T'.

      CONCATENATE <fs_row>-csinsta
                <fs_row>-mnumm
                <fs_row>-myear
              INTO lv_msg_id.

      CREATE OBJECT lorv_link.
      CONCATENATE p_tableview_id
                  lv_msg_id
              INTO lorv_link->id. 
      lorv_link->text = <fs_row>-mnumm_t.
      lorv_link->onclick = 'show_message'.

      CREATE OBJECT lorv_image.
      lorv_image->src           = 'ICON_OKAY'.
      lorv_image->onclientclick = 'alert( )'. "it works without this line! 

      CREATE OBJECT lorv_bee_table.
      lorv_bee_table->add( lorv_link ).
      lorv_bee_table->add( lorv_image ).
      p_replacement_bee = lorv_bee_table.

  ENDCASE.
ENDMETHOD.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

This is just a shot in the dark. I have used the image in an iterator before with the onClick - not onClientClick. Have you tried giving your htmlb:image an ID. I always assign the cell id to any inner htmlb elements in my iterator.


      lorv_image->id = p_cell_id.

daniel_humberg
Contributor
0 Kudos

thomas, you were right.

you can have links and buttons with onClientClicks and without IDs, but for images, you have to add an ID....

Answers (1)

Answers (1)

maximilian_schaufler
Active Contributor
0 Kudos

I'm using quite a lot of javascripts with pre-rendered elements in my iterator, and all errors I found in development where caused by me

What SP are you on?

Have you tried to look at the html source code in your browser, specifically the line that the javascript error occurs?

Maybe this is the next step towards solving your problem.