Web dynpro for ABAP ALV 相关知识

一.动态更改Column Header

DATA lo_cmp_search_usage type ref to if_wd_component_usage. DATA lo_search_value TYPE ref to cl_salv_wd_config_table. DATA lo_search_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .  DATA lr_search_column_setting TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS.  DATA lr_search_column TYPE REF TO CL_SALV_WD_COLUMN.  DATA lr_search_header TYPE REF TO CL_SALV_WD_COLUMN_HEADER.

  lo_cmp_search_usage =   wd_this->wd_cpuse_search_alv( ).
  if lo_cmp_search_usage->has_active_component( ) is initial.
    lo_cmp_search_usage->create_component( ).
  endif.   

lo_search_INTERFACECONTROLLER =   wd_this->wd_cpifc_search_alv( ).
  lo_search_value = lo_search_interfacecontroller->get_model( ).

   lr_search_column_setting ?= lo_search_value.

   CALL METHOD LR_SEARCH_COLUMN_SETTING->GET_COLUMN
    EXPORTING
      ID    = 'FLAG'
    RECEIVING
      VALUE = lr_search_column.
  CALL METHOD lr_search_column->GET_HEADER
    RECEIVING
      VALUE = lr_search_header.
  CALL METHOD lr_search_header->SET_PROP_DDIC_BINDING_FIELD
    EXPORTING
      PROPERTY = IF_SALV_WD_C_DDIC_BINDING=>BIND_PROP_TEXT
      VALUE    = IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE.
  CALL METHOD lr_search_header->SET_TEXT
    EXPORTING
      VALUE = 'FLAG'.

2.动态创建Button

data l_change_button TYPE REF TO cl_salv_wd_fe_button. data l_change_function TYPE REF TO cl_salv_wd_function.   CALL METHOD LO_VALUE->IF_SALV_WD_FUNCTION_SETTINGS~CREATE_FUNCTION
    EXPORTING
      ID    = 'LCHANGE'
    RECEIVING
      VALUE = l_change_function.
  CREATE OBJECT L_CHANGE_BUTTON.
  l_change_button->set_text( 'Change' ).
  l_change_button->set_enabled( abap_false ).
  l_change_function->set_editor( l_change_button ).

3.交通灯显示

   lr_column = lo_upload_value->if_salv_wd_column_settings~get_column( 'Z5TC_ATTRIBUTE5' ).
  CREATE OBJECT lr_image.
  lr_image->SET_SOURCE_FIELDNAME( 'Z5TC_ATTRIBUTE5' ).
  lr_column->set_cell_editor( lr_image ). "Display traffic light images in column 'SEATSOCCC'

4.可编辑模式

    lr_edit_table_settings ?= lo_value.
  lr_edit_table_settings->set_read_only( abap_false ).

  lo_value->if_salv_wd_std_functions~SET_EDIT_CHECK_AVAILABLE( abap_false ).
  lo_value->if_salv_wd_std_functions~SET_EDIT_APPEND_ROW_ALLOWED( abap_false ).
  lo_value->if_salv_wd_std_functions~SET_EDIT_INSERT_ROW_ALLOWED( abap_false ).
  lo_value->if_salv_wd_std_functions~SET_EDIT_DELETE_ROW_ALLOWED( abap_false ).

5. chexbox的创建

   l_search_column = l_search_column_settings->get_column( 'FLAG' ).
  CREATE OBJECT l_input_field
    EXPORTING
      value_fieldname = 'FLAG'.
  l_search_column->set_cell_editor( l_input_field ).

  CREATE OBJECT L_CHECKBOX
    EXPORTING
      CHECKED_FIELDNAME = 'FLAG'.

  CALL METHOD L_SEARCH_COLUMN->SET_CELL_EDITOR
    EXPORTING
      VALUE = L_CHECKBOX.

6.ALV Table可显示行设置

   CALL METHOD LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_VISIBLE_ROW_COUNT
    EXPORTING
      VALUE = 10.

你可能感兴趣的:(web,dynpro)