好男人就是我,我就是你兵哥
分类: Web开发
2016-10-25 18:05:28
原文地址:WebUI 设置颜色 作者:sanly
实现接口:IF_HTMLB_TABLEVIEW_ITERATOR
定义私有属性:DATA Type ZSCC0037_T 表类型
在构造方法:CONSTRUCTOR Instance Method Public 中
METHOD constructor .
me->data = data .
ENDMETHOD.
改变颜色的主要方法:
METHOD if_htmlb_tableview_iterator ~render_cell_start.
DATA:html_bee TYPE REF TO cl_bsp_bee_html,
ls_result TYPE zscc037,
html_str TYPE string,
wf_text TYPE string,
lt_dd03l TYPE TABLE OF dd03l,
ls_dd03l TYPE dd03l.
FIELD-SYMBOLS :
SELECT * INTO TABLE lt_dd03l
FROM dd03l
WHERE tabname = 'ZSCC037' .
READ
TABLE lt_dd03l INTO ls_dd03l
WITH KEY fieldname = p_column_key.
IF sy- subrc EQ 0 .
READ TABLE me->data INTO ls_result INDEX p_row_index .
IF sy-subrc EQ 0 AND ls_result-team_flag EQ 'X'.
ASSIGN COMPONENT p_column_key OF STRUCTURE ls_result TO
IF sy-subrc EQ 0.
wf_text =
IF wf_text IS INITIAL.
wf_text = ` ` .
ENDIF .
ENDIF .
p_style = 'celldesign:GOODVALUE_LIGHT'.
CONCATENATE '
wf_text '
INTO html_str .
CREATE OBJECT html_bee.
html_bee-> add( html = html_str ).
p_replacement_bee = html_bee.
ENDIF .
IF sy-subrc EQ 0 AND ls_result-branch_flag EQ 'X'.
ASSIGN COMPONENT p_column_key OF STRUCTURE ls_result TO
IF sy-subrc EQ 0.
wf_text =
IF wf_text IS INITIAL.
wf_text = ` ` .
ENDIF .
ENDIF .
p_style = 'celldesign:GOODVALUE_LIGHT'.
CONCATENATE '
wf_text '
INTO html_str .
CREATE OBJECT html_bee.
html_bee-> add( html = html_str ).
p_replacement_bee = html_bee.
ENDIF .
ELSE.
ENDIF.
* CASE p_column_key.
* WHEN 'DEPT_DES'.
* WHEN OTHERS.
* ENDCASE.
ENDMETHOD.
《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《
UI调用
METHOD do_prepare_output .
DATA:lr_tab_iterator TYPE REF TO zcl_zcc015_table_iterator,
lr_collection TYPE REF TO if_bol_bo_col ,
lt_result TYPE TABLE OF zscc037 .
CALL
METHOD super->do_prepare_output .
lr_collection ?= me-> typed_context->result ->get_collection_wrapper( ).
CALL
METHOD zcl_cm_service=>get_table
EXPORTING
ir_collection = lr_collection
IMPORTING
et_table = lt_result .
CLEAR me->gv_iterator .
CREATE OBJECT me->gv_iterator TYPE zcl_zcc015_table_iterator
EXPORTING
data = lt_result.
ENDMETHOD.
并在result的视图格式中:
添加
iterator = "<%= controller->GV_ITERATOR %>"