1.19 UI Element:Phase Indicator使用
本实例测试创建Phase Indicator;
运行结果:
1.创建Component,View: V_PHASE_IND;
2.创建Context节点;
创建NODE:NODE_PHASE_STATUS,记录每个阶段状态;
创建Attribute:STA_P1,类型:WDUI_PHASE_STATUS,Phase1阶段状态;
创建Attribute:STA_P2,类型:WDUI_PHASE_STATUS,Phase2阶段状态;
创建Attribute:STA_P3,类型:WDUI_PHASE_STATUS,Phase3阶段状态;
创建Attribute:SELECT_PHASE,类型:String,记录当前选中Phase;
创建NODE:NODE_KEY,记录下拉框选择值;
创建Attribute:STATUS,记录下拉框选择状态;
3.创建Layout UI Element
创建UI Element:
创建PhaseIndicator:PI1
selectedPhase:绑定Attribute, NODE_PHASE_STATUS.SELECT_PHASE;
onSelect:绑定Method,SEL_PI;
创建Phase:P1
status:绑定Attribute, NODE_PHASE_STATUS.STA_P1;
创建Phase:P2
status:绑定Attribute, NODE_PHASE_STATUS.STA_P2;
创建Phase:P3
status:绑定Attribute,NODE_PHASE_STATUS.STA_P3;
创建DropDownByKey:DROPBYKEY
selectedKey:绑定Attribute, NODE_KEY.STATUS;
onSelect:SEL_STATUS;
4.创建Method页签方法
Method:INIT_PHASE_STATUS,初始化Phase status,在WDDOINIT方法中调用;
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:lv_status TYPE wdui_phase_status VALUE '00'.
DATA:ls_status TYPE wd_this->element_node_phase_status.
"获取节点
lo_node = wd_context->get_child_node( wd_this->wdctx_node_phase_status ).
lo_element = lo_node->get_element( ).
"设置初始值
ls_status-select_phase = 'P1'.
ls_status-sta_p1 = lv_status.
ls_status-sta_p2 = lv_status.
ls_status-sta_p3 = lv_status.
lo_node->set_static_attributes(
EXPORTING
static_attributes = ls_status
).
* "设置初始值
* lo_element->set_attribute(
* EXPORTING
* name = 'STA_P1'
* value = lv_status
* ).
* lo_element->set_attribute(
* EXPORTING
* name = 'STA_P1'
* value = lv_status
* ).
*
* lo_element->set_attribute(
* EXPORTING
* name = 'STA_P1'
* value = lv_status
* ).
Method:ONACTIONSEL_PI,Action:SEL_PI对应方法
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:lo_event TYPE REF TO cl_wd_custom_event.
DATA:lv_str TYPE string.
DATA:lv_msg TYPE string.
DATA:lv_phase_status TYPE string.
DATA:lo_dropdownkey TYPE REF TO CL_WD_DROPDOWN_BY_KEY.
lo_event = wdevent.
lv_str = lo_event->get_string(
name = 'PHASE'
).
lv_msg = '选择phase:' && lv_str.
wd_comp_controller->show_msg( msg = lv_msg msg_type = 'S' ).
"设置选择的phase
lo_node = wd_context->get_child_node( wd_this->wdctx_node_phase_status ).
lo_element = lo_node->get_element( ).
lo_element->set_attribute(
EXPORTING
name = 'SELECT_PHASE'
value = lv_str
).
CASE lv_str.
WHEN 'P1'.
lo_element->get_attribute(
EXPORTING
name = 'STA_P1'
IMPORTING
value = lv_phase_status
).
WHEN 'P2'.
lo_element->get_attribute(
EXPORTING
name = 'STA_P2'
IMPORTING
value = lv_phase_status
).
WHEN 'P3'.
lo_element->get_attribute(
EXPORTING
name = 'STA_P3'
IMPORTING
value = lv_phase_status
).
ENDCASE.
"设置当前下拉选择值
lo_dropdownkey ?= wd_this->v_view->get_element( id = 'DROPBYKEY' ).
lo_dropdownkey->set_selected_key( lv_phase_status ).
Method: ONACTIONSEL_STATUS,Action:SEL_STATUS对应方法
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:lo_event TYPE REF TO cl_wd_custom_event.
DATA:lv_key TYPE wdui_phase_status.
DATA:lv_phase TYPE string.
lo_event = wdevent.
"获取选择key
lv_key = lo_event->get_string( name = 'KEY' ).
lo_node = wd_context->get_child_node( wd_this->wdctx_node_phase_status ).
lo_element = lo_node->get_element( ).
lo_element->get_attribute(
EXPORTING
name = 'SELECT_PHASE'
IMPORTING
value = lv_phase
).
"设置对应选择状态
CASE lv_phase.
WHEN 'P1'.
lo_element->set_attribute(
EXPORTING
name = 'STA_P1'
value = lv_key
).
WHEN 'P2'.
lo_element->set_attribute(
EXPORTING
name = 'STA_P2'
value = lv_key
).
WHEN 'P3'.
lo_element->set_attribute(
EXPORTING
name = 'STA_P3'
value = lv_key
).
ENDCASE.