on 04-22-2008 5:06 AM
Hi All,
Our requirement is that depending on the user selection from tree we have to display Columns in ALV.
We have created different variants of ALV also.
The problem is that once i add any col in Displayed ALV Columns through settings button i cannot make it invisible thru configure ALV.
The settings done in ALV always wins.
Could you please tell me is there any way to hide and display columns even though the column will be added in Displayed Col list thru settings button.
Regards,
Arti.
Hi,
suppose i have a column named 'OBJ_ID' AND 'OBJTP'and i want to hide then use the following code
DATA:
lr_comp_alv TYPE REF TO if_wd_component_usage,
lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
lr_config TYPE REF TO cl_salv_wd_config_table,
lr_column TYPE REF TO cl_salv_wd_column,
ls_column TYPE salv_wd_s_column_ref,
lt_columns TYPE salv_wd_t_column_ref.
*... ALV Component Usage
lr_comp_alv = wd_this->wd_cpuse_alv( ).
IF lr_comp_alv->has_active_component( ) IS INITIAL.
lr_comp_alv->create_component( ).
ENDIF.
lr_comp_if_alv = wd_this->wd_cpifc_alv( ).
*... Configure ALV
lr_config = lr_comp_if_alv->get_model( ).
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
lr_config->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
lr_config->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
lr_config->if_salv_wd_std_functions~set_export_allowed( abap_true ).
lt_columns = lr_config->if_salv_wd_column_settings~get_columns( ).
lr_column = lr_config->if_salv_wd_column_settings~get_column('OBJID' ).
LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
when 'OBJID'.
ls_column-r_column->set_visible( value = '99' ).
when 'OBJTP'.
ls_column-r_column->set_visible( value = '99' ).
ENDCASE.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arti,
While configuring the ALV, read the existing columns, and set each one to 'visible' or 'invisible' as required. This should ideally work. If it doesn't work, try the following:
When creating the ALV, do not use the old existing instance of the ALV, each time, create a new instance and configure the instance again.
Hope this helps.
Wenonah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for reply.
But my qn is different.
I am handling the visibiity of cols inside the configure ALV .
The problem is that once u add some col thru settings button of ALV in UI, u cannot make it invisible in Configure ALV.
I want the col to be present in Displayed col list of ALV settings but i should also make it visible or invisiblr thru configure ALV.
This is not happening.
Once i add some col manually in settings of ALV UI, i cannot make it invisible thru configure ALV.
Rgds,
Arti.
Hi Arti,
your ALV is binded to some context right.
and that context has columns.
in method where you are configuring alv.
declare all columns.
and use a flag to set the visibility at runtime.
use the following code:
DATA : lr_alv_if type ref to iwci_salv_wd_table,
lr_alv_model type ref to cl_salv_wd_config_table,
lr_cmp_usage type ref to if_wd_component_usage,
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
ls_column TYPE salv_wd_s_column_ref,
lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_header type ref to cl_salv_wd_column_header,
lr_cmp_usage = wd_this->wd_cpuse_appr_alv( ).
IF lr_cmp_usage->has_active_component( ) is initial.
lr_cmp_usage->create_component( ).
ENDIF.
*... Invoke a Method of the ALV Interfacecontroller
lr_alv_if = wd_this->wd_cpifc_appr_alv( ).
*... Get Model
lr_alv_model = lr_alv_if->get_model( ).
lr_column_settings ?= lr_alv_model.
Set ALV as editable
lr_column_settings->set_read_only( abap_false ).
get table of column settings - each line one column
lt_columns = lr_column_settings->get_columns( ).
loop over table - in each loop another column can be modified
LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
WHEN 'COLUMN NAME'.
"Setting Cell Editor Property
CREATE OBJECT lr_checkbox EXPORTING
checked_fieldname = 'COLUMN NAME'.
lr_checkbox->set_read_only( abap_true ).
"Setting Column Property
ls_column-r_column->SET_CELL_EDITOR( lr_checkbox ).
ls_column-r_column->SET_VISIBLE( EXPORTING value = FLAG ).
......
.......
and call your method by passing the value of flag as 'X' or ' ' as you require.
this will work.
plz feel free to ask any further help if required.
Regards,
Ritwik.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.