cancel
Showing results for 
Search instead for 
Did you mean: 

Row data manipulation in WD SALV_WD_TABLE

0 Kudos

Dear Gurus,

I have a requirement in which i am using the standard WD component SALV_WD_TABLE in my custom WD component. Here i need to disable the checkbox in the first column based on a certain vallue in another column. Ex: I have the ALV displaying check box as first column followed by Purchase Order details like PO number, status, cost center etc. If the status has the value "Ordered" the checkbox should be displayed.

I tried to set the check box with method set_read_only(abap_true). But this disables check boxes on all rows. How do i do this conditionally. I found threads to do something for all rows in a column like setting a particular colour.

Regards,

Manidipa

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

for your column cell editor call the method set_read_only_fieldname and bind it to the context attribute. Depending upon the context attribute value for specific context_element the corresponsing checkbox will be enabled or disabled.

DATA lr_cb TYPE REF TO CL_SALV_WD_UIE_CHECKBOX.

CREATE OBJECT lr_cb

EXPORTING

CHECKED_FIELDNAME = 'FLAG'.

lr_cb->set_read_only_fieldname('FLAG_READONLY').

This should solve your problem.

Thanks,

Rahul

0 Kudos

Hi Rahul,

I still have the same problem. What context attribute binding are you talking about. What should i pass in method set_read_only_fieldname. Should i pass the text 'Ordered'.

My context in component controller has node PO_LIST and has attributes Checkbox and Status_Text. If Status_Text has value 'Ordered' check box should be disabled for that corresponding row is the requirement

The code in my view's WDOINIT using component SALV_WD_TABLE reads like this

DATA: lt_columns TYPE salv_wd_t_column_ref,

lr_column TYPE REF TO cl_salv_wd_column,

ls_column TYPE salv_wd_s_column_ref,

lr_header TYPE REF TO cl_salv_wd_column_header.

lt_columns = wd_this->alv_config_table->if_salv_wd_column_settings~get_columns( ).

LOOP AT lt_columns INTO ls_column.

lr_column = ls_column-r_column.

lr_header = lr_column->get_header( ).

lr_header->set_ddic_binding_field( if_salv_wd_c_ddic_binding=>ddic_bind_none ).

CASE ls_column-id.

WHEN 'CHECKBOX'.

  • create field as checkbox field

CREATE OBJECT lr_checkbox

EXPORTING

checked_fieldname = ls_column-id.

LOOP AT lrt_elements INTO lrs_elements.

lrs_elements->get_static_attributes( IMPORTING static_attributes = ls_po_list ).

IF ls_po_list-status_text = 'Created'.

lr_checkbox->set_read_only( abap_true ).

ELSE.

lr_checkbox->set_read_only( abap_false ).

ENDIF.

ENDLOOP.

lr_column->set_cell_editor( lr_checkbox ).

lr_column->set_h_align( cl_wd_table_column=>e_h_align-center ).

lr_column->r_header->set_text( 'Process PO' ).

ENDLOOP

Edited by: Manidipa Chakravarthi on Oct 19, 2010 8:13 AM

Edited by: Manidipa Chakravarthi on Oct 19, 2010 8:14 AM

Former Member
0 Kudos

Hi mandipa ,

Try using SET_ENABLED() method instead of SET_READ_ONLY().

Pass values abap_true and abap_false as needed.

Thanks,

aditya.

Former Member
0 Kudos

Hi

Take one attribute READONLY type String

Take antoher internal table and move the contents of internal table to another to do manipulation and last bind the copied internal table.

method WDDOINIT .

data : lo_nd_spfli_node TYPE REF TO if_wd_context_node,

lo_el_spfli_noed TYPE REF TO if_wd_context_element,

lt_sflight TYPE if_main=>elements_spfli_node,

lt_final TYPE if_main=>elements_spfli_node,

ls_final TYPE if_main=>element_spfli_node,

ls_flight TYPE if_main=>element_spfli_node.

lo_nd_spfli_node = wd_context->get_child_node( 'SPFLI_NODE' ).

SELECT * FROM

SFLIGHT INTO CORRESPONDING FIELDS OF

TABLE LT_SFLIGHT UP TO 60 ROWS.

LOOP at lt_sflight into ls_flight.

MOVE ls_flight to ls_final.

if ls_final-carrid EQ 'AA'.

ls_final-readonly = abap_FALSE.

ELSE.

ls_final-readonly = ' '.

ENDIF.

APPEND ls_final to lt_final.

lo_nd_spfli_node->bind_table( lt_final ).

ENDLOOP.

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 lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

lo_interfacecontroller = wd_this->wd_cpifc_alv( ).

DATA lv_value TYPE REF TO cl_salv_wd_config_table.

lv_value = lo_interfacecontroller->get_model(

).

CALL METHOD lv_value->if_salv_wd_table_settings~set_read_only

EXPORTING

value = ABAP_FALSE

.

DATA:

lr_input_field TYPE REF TO cl_salv_wd_uie_input_field,

lr_column TYPE REF TO cl_salv_wd_column,

lr_cb TYPE REF TO CL_SALV_WD_UIE_CHECKBOX,

lr_column1 TYPE REF TO cl_salv_wd_column.

lr_column1 = lv_value->if_salv_wd_column_settings~get_column( 'READONLY' ).

CREATE OBJECT lr_cb

EXPORTING

CHECKED_FIELDNAME = 'READONLY'.

lr_column = lv_value->if_salv_wd_column_settings~get_column( 'CARRID' ).

CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CARRID'.

lr_column1->set_cell_editor( lr_cb ).

lr_column->set_cell_editor( lr_input_field ).

lr_cb->set_read_only_fieldname( value = 'READONLY' ).

check with above code it works for your requirement

Thanks,

Tulasi Palnati