on 04-29-2009 10:59 AM
Hi All,
I have an ALV Table with few columns. Some of the columns has got check boxes. Now my question is, depending on the conditions i want to write protect a particular column. Could you tell me how to do it?
Thanks & Regards,
Ravi
Hi Ravi,
By default the column of ALV table are in read only mode but you want them to based on certain contion them first make that column editable by using the following code
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
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_table.
l_column = lr_column_settings->get_column( 'CARRID' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CARRID'.
l_column->set_cell_editor( lr_input_field ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= l_table.
lr_table_settings->set_read_only( abap_false ).
Now create an event handler associated with the ON_CLICK event of alv and used the following code the made the column read only (based on condition)
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= l_table.
lr_table_settings->set_read_only( abap_false ).
I hope it helps.
You can also refer this article[Editing ALV in Web Dynpro for ABAP |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1].
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For ex: there are 5 columns out of which 2 are eidtable and others are non-editable.
Then create 2 context attributes for each set and use the same for the different columns.
for col1 bind the first readonly(READ_ONLY) attiribtue and col2 other context attribute ((READ_ONLY1).
Using the above code
lr_input_field->SET_READ_ONLY_FIELDNAME( 'READ_ONLY). - col1 set this as abap_false for enabled
lr_input_field->SET_READ_ONLY_FIELDNAME( 'READ_ONLY1). - col2 set this as abap_true as disbaled.
Regards,
Lekha.
* Get columns
DATA: lt_columns TYPE salv_wd_t_column_ref ,
ls_columns TYPE salv_wd_s_column_ref .
DATA: l_column_header TYPE REF TO cl_salv_wd_column_header .
lt_columns = l_column_settings->get_columns( ).
LOOP AT lt_columns INTO ls_columns.
CASE ls_columns-id.
WHEN 'column name'.
create object lr_checkbox
EXPORTING checked_fieldname = 'column name'.
lr_checkbox->set_read_only( abap_true ).
ENDCASE.
ENDLOOP.
If the Cell Editor for the column is an Input field you can make it read only using the following code.
WHEN 'ATTRIBUTE NAME' " Column name .
l_column_header = ls_columns-r_column->get_header( ) .
l_column_header->set_ddic_binding_field(
if_salv_wd_c_column_settings=>ddic_bind_none ) .
l_column_header->set_text( 'Column Name' ) .
* Create Editable cell
DATA: l_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT l_input_field
EXPORTING
value_fieldname = ls_columns-id.
ls_columns-r_column->set_cell_editor( l_input_field ) .
l_input_field->set_read_only( abap_true ).
Hope it helps!
Radhika.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.