Question

The problem is I want that some cell of checkbox column in my WD ALV will be editable some cell will be non editable depending on some property.

I make next steps to achieve the required result:

1) Add attribute READONLY type WDY-BOOLEAN to the corresponding node ( attribute CHECK type WDY-BOOLEAN has already added ) .

2) Then in my code I Check some conditions in row of my table and assign attribute READONLY value abap_true or abap_false.

3) Then I bind my node with table. Table is filled correctly, I checked in debugger.

4) Configure my alv:

  DATA: lo_table_settings TYPE REF TO if_salv_wd_table_settings,
  lo_column_settings TYPE REF TO if_salv_wd_column_settings,
  lo_column TYPE REF TO cl_salv_wd_column.
  lo_column_settings ?= lv_value.
  lo_table_settings ?= lv_value.

  lo_column = lv_value->if_salv_wd_column_settings~get_column( 'CHECK' ).
  DATA lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox.

  " create checkbox
  CREATE OBJECT lr_checkbox
  EXPORTING checked_fieldname = 'CHECK'.

  " make our table is editable
  lo_table_settings->set_read_only( abap_false ).

  lo_column = lo_column_settings->get_column( 'CHECK' ).

  " Creating UI Elmenent 'INPUT FIELD' to make the column editable
  DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
  CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CHECK'.

  lr_checkbox->set_read_only_fieldname( value = 'READONLY' ).
  lv_value->if_salv_wd_column_settings~delete_column( ID = 'READONLY' ).

But it doesn't work, all of cells of checkbox column is editable and I don't get non editable cells of checkbox column.

No correct solution

OTHER TIPS

To make a field A editable or readonly, it's only a matter of "using a field B's value to the A's readonly property".

So, as I understand , you have a column which is checkbox, and you want some rows to be editable ,and others to be readonly.

To do so, you won't need to create input field, the only thing you need to do is get the checkbox column reference and set its readonly property bind to the field in your data structure.

if that still doesn't work, check your data, whether the readonly field's value of each record is '', if yes, then of course, every cell of the check will be editable.

Your first step is correct. You added attribute READONLY of type WDY-BOOLEAN to your node and assigned it abap_true value before calling the grid.

The next step is to create input field reference for each field/row which you wanna make editable and assign this reference to the field attribute READONLY and change this attribute only for the lines that fit the condition.

Here is the sample code:

Initial assignment

 loop at lt_table assigning field-symbol(<fs_table>).
  <fs_table>-read_only = abap_true.    " non editable
 endloop.

Setting column editibility

* input type reference
 data lr_input type ref to cl_salv_wd_uie_input_field.

* Retrieving all column id and reference
call method lv_value->if_salv_wd_column_settings~get_columns
   receiving
    value = data(lt_columns).

loop at lt_columns into ls_columns.
* Assigning column reference
data(lr_column) = ls_columns-r_column.

* Creating input field UI Element
create object lr_input
  exporting
   value_fieldname = ls_columns-id.

*Assigning input field to column to make it as editable
call method lr_column->set_cell_editor
  exporting
   value = lr_input.

* binding input field ref to READONLY field  
lr_input->set_read_only_fieldname( value = "READONLY" ).  
endloop.

Making single lines editable based on condition

loop at lt_table assigning field-symbol(<fs_table>).
  if smth = abap_true
    <fs_table>-read_only = abap_false.    " non editable
  endif.
endloop.

Check this guide for reference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top