本文介绍了全屏缺少ALV网格工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的ALV网格,并在其中填充了数据,现在在选择屏幕之后显示了该网格。我不是在使用自定义容器,而是在全屏模式下显示网格。

I've created a simple ALV grid and populated the grid with data, now the grid is displayed after the selection screen. I'm not using custom container and display the grid in full screen.

是否存在ALV网格对象的属性,该属性启用了具有按钮 filter 的工具栏>,排序等,通常位于网格顶部?

Is there a property of ALV grid object that enables toolbar with buttons filter, sort, etc, that is normally on top of the grid?

到目前为止,这就是我所拥有的:

So far this is what I have:

TRY.
  cl_salv_table=>factory(
    IMPORTING
      r_salv_table   = gr_alv
    CHANGING
      t_table        = tbl_data
      ).
CATCH cx_salv_msg.
ENDTRY.

* initialize the alv settings - nothing done here for the moment.
PERFORM define_settings USING gr_alv.

* Display the ALV
gr_alv->display( ).


推荐答案

每个ALV函数在Simple中都实现为单独的CLASS ALV,因此您必须分别处理它们。您不需要自定义控件。

Each ALV function is implemented as a separate CLASS in Simple ALV, so you have to handle them separately. You do not need a custom control.

要添加工具栏:

data: lr_func TYPE REF TO CL_SALV_FUNCTIONS_LIST.
"Functions
lr_func = gr_alv->get_functions( ).
lr_func->set_all( ).

完整的ALV显示:

form display_results.

  data: ls_key        type salv_s_layout_key,

        lo_table      type ref to cl_salv_table,
        lo_cols       type ref to cl_salv_columns_table,
        lo_events     type ref to cl_salv_events_table,
        lo_funcs      type ref to cl_salv_functions_list,
        lo_layout     type ref to cl_salv_layout,
        lo_display    type ref to cl_salv_display_settings,
        lo_selections type ref to cl_salv_selections.

  try.
      call method cl_salv_table=>factory
        exporting
          list_display = abap_false
        importing
          r_salv_table = lo_table
        changing
          t_table      = gt_list.
    catch cx_salv_msg .                                 "#EC NO_HANDLER
  endtry.
  "Events
  create object go_events.
  lo_events = lo_table->get_event( ).
  set handler go_events->double_click for lo_events.

  "Layouts
  ls_key-report = sy-repid.
  lo_layout = lo_table->get_layout( ).
  lo_layout->set_key( ls_key ).
  lo_layout->set_default( abap_true ).
  lo_layout->set_save_restriction( ).
  lo_layout->set_initial_layout( p_var ).

  lo_cols = lo_table->get_columns( ).
  perform change_columns changing lo_cols.

  "Functions
  lo_funcs = lo_table->get_functions( ).
  lo_funcs->set_all( ).

  "Display Settings
  lo_display = lo_table->get_display_settings( ).
  lo_display->set_striped_pattern( abap_true ).

  "Selections
  lo_selections = lo_table->get_selections( ).
  lo_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

  lo_table->display( ).
endform.                   " DISPLAY_RESULTS

这篇关于全屏缺少ALV网格工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 02:57