cancel
Showing results for 
Search instead for 
Did you mean: 

Ediatable ALV Checkbox -Table refreshes every time and shows intial 10 rows

Former Member
0 Kudos

Hi,

I have an checkbox in editable ALV which displays 10 rows intially .It has vertical toolbar .

Requirement is when I check the box one of the corresponding row cell will become editable.

My problem is when I check intial 10 rows it is fine but when I go to 11th record using scrollbar and select checkbox , imemdiately table is being refreshed because my code is in ON_DATA_CHECK event ..How do i get rid of this issue so that cursor stays in the 11th record position only.

IN ON_DATA_CHECK .. i have following code..

LOOP AT lt_alvdata INTO ls_alv_data.

    IF ls_alv_data-seplan = 'X'.

      MOVE ls_data_selections-pstrt TO ls_alv_data-pstart.
   MODIFY lt_alvdata FROM ls_alv_data .
......
ENDLOOP.

LOOP AT lt_columns INTO ls_columns .
    CASE ls_columns-id  .
      WHEN 'TDURAT' .
        DATA:lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
        lr_column = lo_value->if_salv_wd_column_settings~get_column( 'TDURAT' ).
        CREATE OBJECT lr_input_field
          EXPORTING
            value_fieldname = 'TDURAT'.
        lr_input_field->set_read_only_fieldname( 'READ_ONLY' ).
        lr_column->set_cell_editor( lr_input_field ).

 ENDCASE.
  ENDLOOP.


lo_nd_alv_data->bind_table( lt_alvdata ).

What am I missing?

Rgds

Vara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi ,

refer the following manuals

link:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8]

link:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1]

Former Member
0 Kudos

Thank you all for your replies.

Yes Radhika there is a reason for ON_DATA_CHECK.

Everytime user check that box I want to change to my row -cells to ediatble input field, Drop down .

If i have used On_CLICK it wouldn't catch the data changes and thus wouldn't change my cells to input fields & dropdown.

Abhimanyu,

I never used IF_SALV_WD_TABLE_SETTINGS~GET_FIRST_VISIBLE_ROW and

IF_SALV_WD_TABLE_SETTINGS~SET_FIRST_VISIBLE_ROW

Could you be little more specific.

How do i get the current index of the cursor so that it remains in the same place where user-clicked the check box.

rgds

Vara

Former Member
0 Kudos

Hi Vara, Try using R_PARAM->T_MODIFIED_CELLS to get the details of the modified cells. Then using the set_first_visible_row you can achieve ur requirement. Regards, Radhika.

uday_gubbala2
Active Contributor
0 Kudos

Hi Vara,

In my component am trying to display the CARRID, CONNID, FLDATE, PRICE fields from SFLIGHT in my ALV. I have another context attribute CHECK of type WDY_BOOLEAN under the same context node. This attribute would appear as the checkbox column in my ALV. And when I toggle with the state of this checkbox I want to toggle between the enabled/disabled states of PRICE in the corresponding row. Below is the coding I put inside my WDDOMODIFYVIEW for achieving the same:

Regards,

Uday

METHOD wddomodifyview .
  CHECK first_time = abap_true.
  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.


  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,
        lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lt_columns         TYPE        salv_wd_t_column_ref,
        lr_input           TYPE REF TO cl_salv_wd_uie_input_field,
        lr_checkbox        TYPE REF TO cl_salv_wd_uie_checkbox,
        l_value TYPE REF TO cl_salv_wd_config_table.

  FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.


  l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
  l_value = l_ref_interfacecontroller->get_model( ).

  l_value->if_salv_wd_table_settings~set_read_only( abap_false ).

  lr_column_settings ?= l_value.
  lt_columns = lr_column_settings->get_columns( ).

  LOOP AT lt_columns ASSIGNING <fs_column>.
    IF <fs_column>-id = 'PRICE'.
      CREATE OBJECT lr_input
        EXPORTING
          value_fieldname = 'PRICE'.
" This is the key thing to be done here. Binding the readOnly state of PRICE to the CHECK attribute
      lr_input->SET_READ_ONLY_FIELDNAME( value = 'CHECK' ).
      <fs_column>-r_column->set_cell_editor( lr_input ).
    ENDIF.

    IF <fs_column>-id = 'CHECK'.
      CREATE OBJECT lr_checkbox
        EXPORTING
          checked_fieldname = 'CHECK'.
      <fs_column>-r_column->set_cell_editor( lr_checkbox ).
    ENDIF.
  ENDLOOP.
ENDMETHOD.

METHOD wddoinit .
  DATA: lr_node TYPE REF TO if_wd_context_node,
        lt_sflight TYPE wd_this->elements_sflight.

  lr_node = wd_context->get_child_node( name = wd_this->wdctx_sflight ).
  SELECT * FROM sflight UP TO 20 ROWS INTO CORRESPONDING FIELDS OF TABLE lt_sflight.
  lr_node->bind_table( lt_sflight ).
ENDMETHOD.

Former Member
0 Kudos

Uday,

my requirement is not only checkbox but I need to modify the displayed data.

for this reason i was modifying context table and re-binding it.

So in re-binding cursor is being taken to first record alltime.

LOOP AT lt_alvdata INTO ls_alv_data.
 
    IF ls_alv_data-seplan = 'X'.
 
      MOVE ls_data_selections-pstrt TO ls_alv_data-pstart.
   MODIFY lt_alvdata FROM ls_alv_data .
......
ENDLOOP.

***I guess this ibelow statement is causing the issue*
lo_nd_alv_data->bind_table( lt_alvdata ).


rgds

vara

Former Member
0 Kudos

Hi Vara, After rebinding set the selected row by using set_first_visible_row method. IF_SALV_WD_TABLE_SETTINGS~SET_FIRST_VISIBLE_ROW Using R_PARAM->T_MODIFIED_CELLS you can get the index of the modified cells. Regards, Radhika.

Former Member
0 Kudos

Thank you Radhika.

It worked!

I am awarding you full points.

Thank you pradeep for in detail explanation.

I have awarded points.

rgds

Vara

Edited by: Vara K on Aug 17, 2009 8:38 PM

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

Hi Vara,

I tried recreating your scenario. I didn't have to work with any ALV events to achieve your desired functionality. I have 1 boolean attribute at my context level & I have used this both for my checkbox column and also for controlling the readOnly property of 1 of my cells. The toggling between the editable & readOnly states works perfectly & I morever I can even scroll down using my scrollbar & toggle a checkbox. The ALV doesn't get refreshed and also the same toggled checkbox stays in focus. Let me explain my code in a bit more detail.

Regards,

Uday

Former Member
0 Kudos

Hi, Any specific reason for using the On_data_check event ? You could have used the OnClick event to handle the checkbox selection Regards, Radhika.

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Use IF_SALV_WD_TABLE_SETTINGS~GET_FIRST_VISIBLE_ROW and

IF_SALV_WD_TABLE_SETTINGS~SET_FIRST_VISIBLE_ROW

Abhi