Skip to content

Commit 5b55b3b

Browse files
add sample for table cell coloring (#427)
* add sample for table cell coloring * cleanup
1 parent 460477e commit 5b55b3b

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

src/z2ui5_cl_demo_app_000.clas.abap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
10881088
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
10891089
).
10901090

1091+
panel->generic_tile(
1092+
header = 'Cell Coloring'
1093+
press = client->_event( 'z2ui5_cl_demo_app_305' )
1094+
mode = 'LineMode'
1095+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
1096+
).
1097+
10911098
panel->generic_tile(
10921099
header = 'ui.Table I'
10931100
subheader = 'Simple example'
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
CLASS z2ui5_cl_demo_app_305 DEFINITION
2+
PUBLIC
3+
CREATE PUBLIC .
4+
5+
PUBLIC SECTION.
6+
7+
INTERFACES if_serializable_object .
8+
INTERFACES z2ui5_if_app .
9+
10+
TYPES:
11+
BEGIN OF ty_row,
12+
title TYPE string,
13+
value TYPE string,
14+
END OF ty_row .
15+
16+
DATA:
17+
t_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY.
18+
19+
PROTECTED SECTION.
20+
DATA client TYPE REF TO z2ui5_if_client.
21+
22+
METHODS set_view.
23+
24+
ENDCLASS.
25+
26+
27+
CLASS z2ui5_cl_demo_app_305 IMPLEMENTATION.
28+
29+
METHOD set_view.
30+
31+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
32+
DATA(page) = view->shell(
33+
)->page(
34+
title = 'abap2UI5 - Tables and cell colors'
35+
navbuttonpress = client->_event( 'BACK' )
36+
shownavbutton = abap_true ).
37+
38+
page->_generic(
39+
name = `style`
40+
ns = `html`
41+
)->_cc_plain_xml(
42+
`td:has([data-color="red"]){ `
43+
&& ` background-color: red;`
44+
&& `}`
45+
&& ``
46+
&& `td:has([data-color="green"]){`
47+
&& ` background-color: green;`
48+
&& `}`
49+
&& ``
50+
&& `td:has([data-color="blue"]){`
51+
&& ` background-color: blue;`
52+
&& `}`
53+
&& ``
54+
&& `td:has([data-color="orange"]){`
55+
&& ` background-color: orange;`
56+
&& `}`
57+
&& ``
58+
&& `td:has([data-color="grey"]){`
59+
&& ` background-color: grey;`
60+
&& `}`
61+
&& ``
62+
&& `td:has([data-color="yellow"]){`
63+
&& ` background-color: yellow;`
64+
&& `}` ).
65+
66+
DATA(tab) = page->table(
67+
items = client->_bind_edit( t_tab )
68+
mode = 'MultiSelect'
69+
)->header_toolbar(
70+
)->overflow_toolbar(
71+
)->title( 'change cell color'
72+
)->get_parent( )->get_parent( ).
73+
74+
tab->columns(
75+
)->column(
76+
)->text( 'Title' )->get_parent(
77+
)->column(
78+
)->text( 'Color' )->get_parent( ).
79+
80+
tab->items( )->column_list_item(
81+
)->cells(
82+
)->text( text = '{TITLE}'
83+
)->get(
84+
)->custom_data(
85+
)->core_custom_data( key = 'color' value = '{VALUE}' writetodom = abap_true
86+
)->get_parent(
87+
)->get_parent(
88+
)->input( value = '{VALUE}' enabled = abap_true ).
89+
90+
client->view_display( view->stringify( ) ).
91+
92+
ENDMETHOD.
93+
94+
95+
METHOD z2ui5_if_app~main.
96+
97+
me->client = client.
98+
99+
IF z2ui5_if_app~check_initialized = abap_false.
100+
t_tab = VALUE #(
101+
( title = 'entry 01' value = 'red' )
102+
( title = 'entry 02' value = 'blue' )
103+
( title = 'entry 03' value = 'green' )
104+
( title = 'entry 04' value = 'yellow' )
105+
( title = 'entry 05' value = 'orange' )
106+
( title = 'entry 06' value = 'grey' ) ).
107+
108+
set_view( ).
109+
ENDIF.
110+
111+
CASE client->get( )-event.
112+
WHEN 'BACK'.
113+
client->nav_app_leave( ).
114+
ENDCASE.
115+
116+
ENDMETHOD.
117+
ENDCLASS.

src/z2ui5_cl_demo_app_305.clas.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>Z2UI5_CL_DEMO_APP_305</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>tab - editable</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
</VSEOCLASS>
14+
</asx:values>
15+
</asx:abap>
16+
</abapGit>

0 commit comments

Comments
 (0)