cancel
Showing results for 
Search instead for 
Did you mean: 

Checkbox - ALV Editable

Former Member
0 Kudos

Hi,

This is for an editable ALV.

I need a checkbox as one of the column and 2 columns should become editable upon Checkbox selection.

For this I followed ALV tutorial (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1) and made columns editable.Following some suggestions from sdn I also created additional attribute under the the same node type boolean.

1- How do i bind this attribute to the editable property of my 2 inputs fields? so that They become editable on check?

2- If user enters today's date in column 1 (06/12/2009) , I should fill dynamically column2 with a week day after date (06/19/2009),

Rgds

Vara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

when ur creating your checkbox, bind the readobly property as follows:

lr_checkbox->SET_READ_ONLY_FIELDNAME( 'ATRRIBUTE NAME' ).

Regards,

Radhika.

Former Member
0 Kudos

Lekha,

I am following your steps.

1-Created READ_ONLY attribute with CHAR1 in same NODE.

2-Created Checkbox in Column 1 in WDOINIT method (followed ALV tutorial).

3-Created Onclick event and did coding in onclick method.( first I did not choose any event )

When I run first time I see checkbox column in editable mode but when I click it is not making my 2 columns editable. I tried debugging.. it is not even taking to that code.

4- I tried by choosing ON_CLICK event and have the same issue.

Where am i going wrong???

METHOD wddoinit .

*   lr_table_settings->set_read_only( abap_false ).
*  ***Checkbox Creation on ALV column
  lr_column = l_value->if_salv_wd_column_settings~get_column( 'SEPLAN' ).
  CREATE OBJECT lr_checkbox
    EXPORTING
      checked_fieldname = 'SEPLAN'.

  lr_column->set_cell_editor( lr_checkbox ).
ENDMETHOD.

METHOD onclick .

  
  DATA: lr_column TYPE REF TO cl_salv_wd_column.

* set read only mode to false (and display edit toolbar)
  DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
  lr_table_settings ?= l_value.
  lr_table_settings->set_read_only( abap_false ).


  DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
  lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
  lr_column_settings ?= l_value.


  lr_column = lr_column_settings->get_column( 'TDURAT' ).
  CREATE OBJECT lr_input_field
    EXPORTING
      value_fieldname = 'TDURAT'.
  lr_column->set_cell_editor( lr_input_field ).

endmethod.

Edited by: Vara K on Jun 16, 2009 12:17 AM

Edited by: Vara K on Jun 16, 2009 12:41 AM

Former Member
0 Kudos

Hi,

Create checkbox and READ_ONLY attributes and bind the read_only attribute to the INPUTFIELD object that you create for that column.

Initally both the other columns are non-editable right

Loop at lt_table into ls_table.
ls_table-read_only = abap_true       "NOn Editable
modify table
endloop.
Bind table to node.

Now get the column references and set_read_only_fieldname('READ_ONLY') for that column.

ONCLICK event based on the index ( the one you cilck on the checkbox)

Loop at lt_table into ls_table.

if sy-tabix eq index.                     "R_param index
read_only = abap_false.
else.
ls_table-read_only = abap_true       "NOn Editable
endif.
modify table
endloop.

Bind the table to node.

Regards,

Lekha.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When you have successfully created the Checkbox for that ALV. Also create other attribute for READ_ONLY to the node to which the ALV is bound.

1. Before you bind the table, set the READ_ONLY attribute as abap_true for all the rows.

2. Get the column settings, for those 2 columns(that you want to make editable), create an Input field and use the method SET_READ_ONLY_FIELDNAME('READ_ONLY') and for column 1 create a checkbox.

3. Write the code in the ONCLICK event of the checkbox for that ALV -

Refer this thread -

4. In this click event of the ALV, set the READ_ONLY as abap_false for that row by getting the index.

and bind the table again when the checkbox is checked.

Now you can see that when checkbox is checked then you can make those columns editable for that row.

Check out these links -

Regarding date, write the code in the ONDATACHECK or ONCELLACTION of the column1.

When this action is implemented, then you get the index and get the reocrd at that index using if_wd_context_ndode ->get_element( index = index) and get the date.

To this date add date to get the next week and modify the table using this record and bind the table again.

DATA: w_date tye sy-datum, lv_tabix type sy-tabix
w_date = sy-datum.
add 7 to w_date+6(2).
loop at lt_table into ls_table.
lv_tabix = sy-tabix.
if lv_tabix = lv_index (You can get it from the R_PARAM index)
ls_table-column2 = w_date.
endif.
modify lt_table from ls_table index sy-tabix.
endloop.
lr_node->bind_table( lt_table).

l

Regards,

Lekha.