cancel
Showing results for 
Search instead for 
Did you mean: 

deleting a row in a tableView

Former Member
0 Kudos

Hi all,

I have a similar problem like Bruno Lucattelli in his post <b>Problem on refreshing tableview's content</b>:

If I want to delete a selected row in a tableView, the row after the selected row is obviously being deleted. For example: row 2 is selected, the input fields of row 3 are restored wrongly from the request of row 2 (as described by Brian in Bruno's post).

The difference to Bruno's problem is that I'm using the structure TABLEVIEWCONTROL in the iterator interface for the definition of columns (<i>if_htmlb_tableview_iterator</i>) and the rendering of cells.

Brian mentioned some 'dirty tricks' in his last reply to Bruno's post.

Therefore I tried his suggestion and changed the ID of the tableView for each new server round-trip. But this doesn't work either in my case.

Do you have another 'dirty tricks' to solve my problem?

Thanks!

Stefan

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181879
Active Contributor
0 Kudos

No immediate ideas. Maybe you could post a minimal version of your code, so that we can just look at it. Specifically we am interested in the way you call the tableView, and the iterator code. Once we have this, I will ask better guru than myself to eyeball it.

Really changing the tableView ID should completely make it impossible to restore any values.

Former Member
0 Kudos

Hi Brian,

hi all,

I'm using MVC.

<b>tableView call:</b>

The tableView id is changed on every server round trip.

<htmlb:tableView id               = "<%= vs_id %>"
                 headerText       = "Korrekturen"
                 headerVisible    = "true"
                 visibleRowCount  = "8"
                 selectionMode    = "LINEEDIT"
                 selectedRowIndex = "<%= selected_row %>"
                 table            = "//model/git_buffer_corr"
                 iterator         = "<%= model->gcl_corr_iterator %>"/>

<b>Iterator:</b>

METHOD if_htmlb_tableview_iterator~get_column_definitions .

  CLEAR p_column_definitions.
  CLEAR p_overwrites.

  DATA tv_column TYPE tableviewcontrol.

  tv_column-columnname          = '0COSTELMNT'.
  tv_column-edit                = 'X'.
  tv_column-title               = 'Kostenart'.
  APPEND tv_column TO p_column_definitions.

  CLEAR tv_column.
  tv_column-columnname          = '0AMOUNT'.
  tv_column-title               = 'Betrag'.
  tv_column-edit                = 'X'.
  APPEND tv_column TO p_column_definitions.


ENDMETHOD.

METHOD if_htmlb_tableview_iterator~render_cell_start .

  DATA: col1_ddlb TYPE REF TO cl_htmlb_dropdownlistbox,
        value     TYPE string.

  CASE p_column_index.
    WHEN 1.
      IF p_edit_mode IS NOT INITIAL.
        CREATE OBJECT col1_ddlb.

        value = p_row_index.
        CONDENSE value.
        CONCATENATE '//model/git_buffer_corr[' value '].0costelmnt' INTO value.
        col1_ddlb->_selection = value.
        col1_ddlb->_table = '//model/git_corr_costelmnt'.
        col1_ddlb->nameofkeycolumn = 'KOART'.
        col1_ddlb->nameofvaluecolumn = 'KOART'.
        p_replacement_bee = col1_ddlb.

      ENDIF.
  ENDCASE.

ENDMETHOD.

<b>Event handling:</b>

METHOD DO_HANDLE_DATA.

    [...]

    event = cl_htmlb_manager=>get_event( request ).
    IF event IS NOT INITIAL.

      CASE event->name.
        WHEN 'tableView'.
          table_event ?= event.
          m_selected_row = table_event->selectedrowindex.
          CONDENSE m_selected_row.

        WHEN 'button'.
          button_event ?= event.

          CASE button_event->server_event.
            WHEN 'new_entry'.
              APPEND INITIAL LINE TO model->git_buffer_corr.

             vi_lines = LINES( model->git_buffer_corr ).
             m_selected_row = vi_lines.
            WHEN 'delete_entry'.
              vi_index = m_selected_row.

              IF vi_index > 0.
                DELETE model->git_buffer_corr INDEX vi_index.
              ENDIF.

              m_selected_row = 0.
            WHEN OTHERS.
          ENDCASE.
      ENDCASE.
    ENDIF.
ENDMETHOD.

I hope, I sent all relevant code fragments...

Thanks!

Stefan