WebDynpro ABAP 中WDALV 的 ToolBar 设置

ALV FUNCTION:

TOOLBAR上可以对两类TOOLBAR进行显示和设置,分别为系统标准及用户自定义的。

1。系统标准(Standard Functions), 默认ALV显示,可以看到“视图”,“显示为”,“打印”……等

可以通过接口为 if_salv_wd_std_functions 设置其是否显示,显示位置,布局等。

2。用户自定义(Application Functions),用户可以自定义添加各种UI及事件。

可以通过接口为 if_salv_wd_function_settings来实现,UI的类型,位置等。通过继承ALV的ON_FUNCTION加入处理事件。

 

用户可生成的控件种类:Button,ToggleButton,DropDownByKey,DropDownByIndex,InputField,LinkToURL,linkToAction,ButtonChoice

 

用户自定义的TOOLBAR,简单实现如下:

在CONTEXT中新建节点FUNCTION_ELEMENTS,与WDALV中的FUNCTION_ELEMENTS映射绑定。FUNCTION_ELEMENT下新建CHECKED,CHOICE,INFUTFIELD,DROPYDOWNBYKEY等属性,供生成UI时使用,以及触发操作后从此读值。

 

DATA : R_TABLE TYPE REF TO  CL_SALV_WD_CONFIG_TABLE。

  METHOD configure_alv . “ALV上TOOLBAR设置

*... check ALV component usage
  DATA:
    lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.

  lr_salv_wd_table_usage = wd_this->wd_cpuse_salv_wd_table( ).
  IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
    lr_salv_wd_table_usage->create_component( ).
  ENDIF.

*... get ALV component
  DATA:
    lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.

  lr_salv_wd_table = wd_this->wd_cpifc_salv_wd_table( ).

*... (1) get ConfigurationModel from ALV Component
  wd_this->r_table = lr_salv_wd_table->get_model( ).

* ...(2) init ConfigurationModel
*... init Toolbar
  DATA:
    lr_functions TYPE REF TO if_salv_wd_function_settings.

  lr_functions ?= wd_this->r_table.

  DATA:
    lr_function TYPE REF TO cl_salv_wd_function.

  DATA:
    lr_button          TYPE REF TO cl_salv_wd_fe_button,
    lr_toggle_button   TYPE REF TO cl_salv_wd_fe_toggle_button,
    lr_dropdown_by_key TYPE REF TO cl_salv_wd_fe_dropdown_by_key,
    lr_dropdown_by_idx TYPE REF TO cl_salv_wd_fe_dropdown_by_idx,
    lr_input_field     TYPE REF TO cl_salv_wd_fe_input_field,
    lr_link_to_action  TYPE REF TO cl_salv_wd_fe_link_to_action,
    lr_link_to_url     TYPE REF TO cl_salv_wd_fe_link_to_url,
    lr_button_choice   TYPE REF TO cl_salv_wd_fe_button_choice.

  lr_function = lr_functions->create_function( 'MYLEFTBUTTON' ).
  CREATE OBJECT lr_button.
  lr_button->set_text( 'MYLEFTBUTTON' ).
  lr_function->set_editor( lr_button ).

  lr_function = lr_functions->create_function( 'MYTOGGLEBUTTON' ).
  CREATE OBJECT lr_toggle_button
    EXPORTING
      checked_elementname = 'CHECKED'.
  lr_toggle_button->set_text( 'MYTOGGLEBUTTON' ).
  lr_toggle_button->set_image_source( 'ICON_FLIGHT' ).
  lr_toggle_button->set_checked_image_source( 'ICON_FLIGHT' ).
  lr_function->set_editor( lr_toggle_button ).

  lr_function = lr_functions->create_function( 'MYDROPDOWNBYKEY' ).
  CREATE OBJECT lr_dropdown_by_key
    EXPORTING
      selected_key_elementname = 'DROPDOWNBYKEY'.
  lr_dropdown_by_key->set_label_text( 'MYDROPDOWNBYKEY' ).
  lr_function->set_editor( lr_dropdown_by_key ).

  lr_function = lr_functions->create_function( 'MYDROPDOWNBYINDEX' ).
  CREATE OBJECT lr_dropdown_by_idx
    EXPORTING
      texts_elementname = 'DROPDOWNBYINDEX.VALUE'.
  lr_dropdown_by_idx->set_label_text( 'MYDROPDOWNBYINDEX' ).
  lr_function->set_editor( lr_dropdown_by_idx ).

  lr_function = lr_functions->create_function( 'MYINPUTFIELD' ).
  CREATE OBJECT lr_input_field
    EXPORTING
      value_elementname = 'INPUTFIELD'.
  lr_input_field->set_label_text( 'MYINPUTFIELD' ).
  lr_function->set_editor( lr_input_field ).

  lr_function = lr_functions->create_function( 'MYLINKTOACTION' ).
  CREATE OBJECT lr_link_to_action.
  lr_link_to_action->set_text( 'MYLINKTOACTION' ).
  lr_function->set_editor( lr_link_to_action ).

  lr_function = lr_functions->create_function( 'MYLINKTOURL' ).
  CREATE OBJECT lr_link_to_url.
  lr_link_to_url->set_text( 'MYLINKTOURL' ).
  lr_link_to_url->set_reference( 'http://www.amazon.de' ).
  lr_function->set_editor( lr_link_to_url ).

  lr_function = lr_functions->create_function( 'MYBUTTONCHOICE' ).
  CREATE OBJECT lr_button_choice.
  lr_button_choice->set_text( 'MYBUTTONCHOICE' ).
  lr_function->set_editor( lr_button_choice ).
  lr_button_choice->set_repeat_selected_action( abap_true ).
*  lr_button_choice->set_selected_action_item( 'CHOICE_3' ).
  lr_button_choice->set_sel_action_itm_elementname( 'CHOICE' ).

  DATA:
    lr_choice TYPE REF TO cl_salv_wd_menu_action_item.

  CREATE OBJECT lr_choice
    EXPORTING
      id = 'CHOICE_1'.
  lr_choice->set_text( 'Choice1' ).                         "#EC NOTEXT
  lr_button_choice->add_choice( lr_choice ).

  CREATE OBJECT lr_choice
    EXPORTING
      id = 'CHOICE_2'.
  lr_choice->set_text( 'Choice2' ).                         "#EC NOTEXT
  lr_button_choice->add_choice( lr_choice ).

  CREATE OBJECT lr_choice
    EXPORTING
      id = 'CHOICE_3'.
  lr_choice->set_text( 'Choice3' ).                         "#EC NOTEXT
  lr_button_choice->add_choice( lr_choice ).

  lr_function = lr_functions->create_function_right( 'MYRIGHTBUTTON' ).
  CREATE OBJECT lr_button.
  lr_button->set_text( 'MYRIGHTBUTTON' ).
  lr_function->set_editor( lr_button ).

ENDMETHOD.

 

METHOD:ON_ALV_FUNCTION 继承ALV中的ON_FUNCTION事件:

METHOD on_alv_function .
  CASE r_param->id.
    WHEN 'FROM_SUB'.  
      wd_this->on_from_sub( ).
    WHEN 'CREAT_SUB'.  
      wd_this->on_creat_sub( ).

    ......
  ENDCASE.

ENDMETHOD.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SAP_ABAP_WebDynpro开发(文) http://scnblogs.techweb.com.cn/tcsapbw/archives/5.html 一、WebDynpro For ABAP 基础 案例一:WebDynpro环境准备 - 6 - 案例二: Tabtrip与close事件 - 10 - 案例三: HorizonalContextPanel及其事件 - 12 - 案例四: ContextPanel及其事件 - 18 - 案例五: 使用RowRepeater - 25 - 案例六: Table:Scroll以及header(append与delete) - 30 - 案例七: Table:Group(Column & Row) 以及firstActualRow,FirstVisiableRow - 34 - 案例八: Table: Filter - 41 - 案例九: Table: Sort - 46 - 案例十: Table: Row Popin 与 Cell Popin,以及Business Graphic - 53 - 案例十一: Table: 使用TableSummaryCell作subtotal - 67 - 案例十二: Table: 实现TableSummaryCell的方法(展开或隐藏) - 72 - 案例十三: Table:动态创建并实现TableSummaryCell的方法(展开或隐藏) - 80 - 案例十四: Table:Context Change History的使用 - 89 - 案例十五: Table:Tree table(TreeByKeyTableColumn)- One level - 100 - 案例十六: Table:Tree table(TreeByKeyTableColumn)- multi level - 106 - 案例十七: Table:Tree table(TreeByKeyTableColumn)- Recursive Node - 112 - 案例十八: 使用DateNavigator - 121 - 案例十九: 使用RoadMap - 134 - 案例二十: 使用Phase Indicator - 149 - 案例二十一: 使用Select Options - 156 - 案例二十二: 简单使用Reuse Component - 162 - 案例二十三: 使用OTR并进行翻译 - 166 - 案例二十四: 利用Request进行SE63OTR的翻译 - 170 - 案例二十五: UI Element的居显示(Vertical and horizonal) - 173 - 案例二十六: 使用Grid layout将UI element放置在不同的位置(左右缩进等) - 183 - 案例二十七: 使用NavigationList(使用Recursion Node) - 186 - 案例二十八: 使用CheckBox 和Checkbox Group - 193 - 案例二十九: 使用OVS - 197 - 案例三十: 使用Supply Function - 207 - 案例三十一: 使用Message - 214 - 案例三十二:使用DropdownlistByKey 和DropdownlistByIndex - 223 - 案例三十三:使用External Window以及Dialog Boxes - 227 - 案例三十四:实现Input field的cursor定位 - 246 - 案例三十五:从View上实现WebDynpro的log out - 248 - 案例三十六:从Component Controller实现WebDynpro的log out - 252 - 案例三十七:实现Mandatory Fields的check - 256 - 案例三十八:使用Assistance Class 案例三十九:WD防止Time out
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值