cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ALV columns hide and visible

Former Member
0 Kudos

Hi guru's,

I am using ALV.

Initially I need to display 5 columns in alv. I have one button called display. Once that action triggered one more column (totally 6 columns)has to be display in ALV.

I tired by hiding column 6 using set_visible method in INIT and in display action button i wrote code to read all columns.

but is not working.

<Display button > is not inside the ALV. its another UI element in same view.

how to display hided column in ALV?

Thanks & Regards,

Meena.R

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member188219
Participant
0 Kudos

lr_columns TYPE REF TO cl_salv_columns.

  DATA : lr_column     TYPE REF TO cl_salv_column."Class for single column

TRY .""hide

        MOVE lr_columns->get_column( columnname =  lcstcvr_w5  ) TO lr_column.

        lr_column->set_technical( if_salv_c_bool_sap=>true ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

might be helpful

Former Member
0 Kudos

Hi Meenachi,

Pls close the thread if your issue has been resolved else revert back .

Thanks

KH

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

  DATA lt_column TYPE salv_wd_t_column_ref.
  DATA lr_column TYPE salv_wd_s_column_ref.

lt_column = lv_value->if_salv_wd_column_settings~get_columns( ).

IF < CHECKING CONDITION TO ENABLE COLUMN>.

LOOP AT lt_column INTO lr_column.

CASE lr_column-id.

WHEN '<your col name>'.

  lr_column-r_column->set_visible(   value = cl_wd_uielement=>e_visible-visible   ).

ENDCASE.

ENDLOOP.

ELSE. "To hide columns

LOOP AT lt_column INTO lr_column.

CASE lr_column-id.

WHEN '<your col name>'.

  lr_column-r_column->set_visible(   value = cl_wd_uielement=>e_visible-none   ).

ENDCASE.

ENDLOOP.

ENDIF.

PFB the snapshots for reference where i'm showing few columns and hiding them based on certain condition as per my requirement.

1) Showing all columns in my ALV table.

2) Now columns Business process, Sub process,Function are hidden based on my condition.

Hope this helps you.

Good Luck.

KH

harsha_jalakam
Active Contributor
0 Kudos

Hi,

We can enable the hidden column, through the following code.

lo_cmp_usage =   wd_this->wd_cpuse_flight_tree( ).

if lo_cmp_usage->has_active_component( ) is initial.
   lo_cmp_usage->create_component( ).
endif.

DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_flight_tree( ).

   DATA lv_value TYPE ref to cl_salv_wd_config_table.
   lv_value = lo_interfacecontroller->get_model(
   ).

   DATA: column_settings TYPE REF TO if_salv_wd_column_settings,
         column          TYPE REF TO cl_salv_wd_column.

   column_settings ?= lv_value.

   column = column_settings->get_column( 'CARRID' )." Carrid is the name of the column.
   column->set_visible( ).



Regards,


Harsha