Block Layout with custom background color set for the cells
Block Layout in which all cells use the same background color set and different color shade.
Z2UI5_CL_SMPC_APP_140
Controls
sap.ui.layout
UI5 1.98
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_140- Source file
z2ui5_cl_smpc_app_140.clas.abap↗- Library
- sap.ui.layout
- UI5 entity
sap.ui.layout.BlockLayout- Demo kit sample
sap.ui.layout.sample.BlockLayoutCustomBackground- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.98
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: blocklayout, block, layout, sap.ui.layout, backgrounds, html, vbox, hbox, label, select, item, blocklayoutrow
Controls it builds
- sap.m.HBox
- sap.m.Input
- sap.m.Label
- sap.m.Select
- sap.m.Text
- sap.m.TextArea
- sap.m.VBox
- sap.ui.core.HTML
- sap.ui.core.Icon
- sap.ui.core.Item
- sap.ui.core.mvc.View
- sap.ui.layout.BlockLayout
- sap.ui.layout.BlockLayoutCell
- sap.ui.layout.BlockLayoutRow
- sap.ui.layout.form.SimpleForm
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smpc_app_140.clas.abap — 212 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords blocklayout block layout sap.ui.layout backgrounds html vbox hbox label select item blocklayoutrow
" @summary Block Layout in which all cells use the same background color set and different color shade.
CLASS z2ui5_cl_smpc_app_140 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA colorset TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_140 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
colorset = `ColorSet5`.
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns:f` v = `sap.ui.layout.form`
)->a( n = `xmlns` v = `sap.m`
" the sample's own resources/sample.css - the view carries
" customCellImageBackground and the rule behind it has to come with it.
" Its background-image is relative in the original; absolutized to the
" OpenUI5 host per the asset-URL rule. \{ \} escaped: the XMLView parser
" reads an unescaped brace as a binding
)->tag( n = `HTML` ns = `core`
)->a( n = `content` v = `<style>.customCellImageBackground\{color:#fff;` &&
`background-image:url("https://sdk.openui5.org/test-resources/sap/ui/layout/demokit/sample/BlockLayoutCustomBackground/resources/Night_sky.jpg");` &&
`background-size:100% auto;background-position:0 80%\}` &&
`.customCellImageBackground .sapUiBlockCellContent,` &&
`.customCellImageBackground .sapUiBlockCellContent .sapMText\{color:#fff\}</style>`
)->ele( `VBox`
)->ele( `HBox`
)->a( n = `alignItems` v = `Center`
)->a( n = `class` v = `sapUiContentPadding`
)->tag( `Label`
)->a( n = `text` v = `Color set for all cells`
)->a( n = `showColon` v = `true`
)->a( n = `class` v = `sapUiTinyMarginEnd`
)->ele( `Select`
)->a( n = `selectedKey` v = client->_bind( colorset )
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet1`
)->a( n = `text` v = `ColorSet1`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet2`
)->a( n = `text` v = `ColorSet2`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet3`
)->a( n = `text` v = `ColorSet3`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet4`
)->a( n = `text` v = `ColorSet4`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet5`
)->a( n = `text` v = `ColorSet5`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet6`
)->a( n = `text` v = `ColorSet6`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet7`
)->a( n = `text` v = `ColorSet7`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet8`
)->a( n = `text` v = `ColorSet8`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet9`
)->a( n = `text` v = `ColorSet9`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet10`
)->a( n = `text` v = `ColorSet10`
)->tag( n = `Item` ns = `core`
)->a( n = `key` v = `ColorSet11`
)->a( n = `text` v = `ColorSet11 (transparent in SAP Horizon theme)`
)->end(
)->end(
)->ele( n = `BlockLayout` ns = `l`
)->a( n = `id` v = `blockLayout`
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `Cells with Custom Color (Shade A)`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeA`
)->end(
)->end(
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `The Title`
)->a( n = `titleAlignment` v = `Center`
)->a( n = `class` v = `customCellImageBackground`
)->tag( `Text`
)->a( n = `text` v = `Donec bibendum diam nibh, sit amet ornare ante fermentum sed. Ut vulputate justo at orci sollicitudin.`
)->end(
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `An Icon (Shade B)`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeB`
)->tag( n = `Icon` ns = `core`
)->a( n = `src` v = `sap-icon://add-activity`
)->end(
)->end(
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `Simple Form (Shade C)`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeC`
)->ele( n = `SimpleForm` ns = `f`
)->a( n = `editable` v = `true`
)->a( n = `backgroundDesign` v = `Transparent`
)->a( n = `layout` v = `ResponsiveGridLayout`
)->tag( `Label`
)->a( n = `text` v = `sap.m.Input`
)->tag( `Input`
)->a( n = `type` v = `Text`
)->a( n = `placeholder` v = `Enter Name ...`
)->tag( `Label`
)->a( n = `text` v = `sap.m.TextArea`
)->tag( `TextArea`
)->a( n = `placeholder` v = `Please add your comment...`
)->a( n = `rows` v = `6`
)->a( n = `maxLength` v = `255`
)->a( n = `width` v = `100%`
)->tag( `Label`
)->a( n = `text` v = `sap.m.Text`
)->tag( `Text`
)->a( n = `text` v = `Donec bibendum diam nibh, sit amet ornare ante fermentum sed. Ut vulputate justo at orci sollicitudin, in gravida lectus aliquam. Vivamus tortor lorem, semper et diam ac, ` &&
`faucibus suscipit metus. Curabitur eget aliquet purus, id vestibulum sapien. Cras vitae imperdiet felis. Fusce placerat velit orci, at tempor nisl aliquam laoreet. ` &&
`Aliquam in sapien sit amet tortor laoreet feugiat id in ligula.`
)->end(
)->end(
)->end(
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `Right Aligned Title (Shade D)`
)->a( n = `titleAlignment` v = `Right`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeD`
)->tag( `Text`
)->a( n = `text` v = `Morbi id ullamcorper lorem, vestibulum facilisis velit. Ut elementum aliquam nisl a pretium. Donec auctor mattis convallis. Aenean sodales tortor nec facilisis fringilla. ` &&
`Nam feugiat nulla at diam sollicitudin pretium. Sed at lacus volutpat, finibus arcu ultricies, convallis elit. Aliquam sollicitudin tortor sit amet mi consequat ` &&
`fringilla. Fusce nisl leo, tempor et nulla id, pellentesque suscipit augue. Morbi cursus molestie tellus. Ut volutpat orci interdum, condimentum risus sed, iaculis ` &&
`tellus. Proin nisi eros, tristique nec tortor quis, suscipit sodales dui.`
)->end(
)->end(
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `Left Aligned Title (Shade E - Only Available for SAP Quartz and Horizon Themes)`
)->a( n = `titleAlignment` v = `Left`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeE`
)->tag( `Text`
)->a( n = `text` v = `Morbi id ullamcorper lorem, vestibulum facilisis velit. Ut elementum aliquam nisl a pretium. Donec auctor mattis convallis. Aenean sodales tortor nec facilisis fringilla. ` &&
`Nam feugiat nulla at diam sollicitudin pretium. Sed at lacus volutpat, finibus arcu ultricies, convallis elit. Aliquam sollicitudin tortor sit amet mi consequat ` &&
`fringilla. Fusce nisl leo, tempor et nulla id, pellentesque suscipit augue. Morbi cursus molestie tellus. Ut volutpat orci interdum, condimentum risus sed, iaculis ` &&
`tellus. Proin nisi eros, tristique nec tortor quis, suscipit sodales dui.`
)->end(
)->end(
)->ele( n = `BlockLayoutRow` ns = `l`
)->ele( n = `BlockLayoutCell` ns = `l`
)->a( n = `title` v = `Default Aligned Title (Shade F - Only Available for SAP Quartz and Horizon Themes)`
)->a( n = `backgroundColorSet` v = client->_bind( colorset )
)->a( n = `backgroundColorShade` v = `ShadeF`
)->tag( `Text`
)->a( n = `text` v = `Morbi id ullamcorper lorem, vestibulum facilisis velit. Ut elementum aliquam nisl a pretium. Donec auctor mattis convallis. Aenean sodales tortor nec facilisis fringilla. ` &&
`Nam feugiat nulla at diam sollicitudin pretium. Sed at lacus volutpat, finibus arcu ultricies, convallis elit. Aliquam sollicitudin tortor sit amet mi consequat ` &&
`fringilla. Fusce nisl leo, tempor et nulla id, pellentesque suscipit augue. Morbi cursus molestie tellus. Ut volutpat orci interdum, condimentum risus sed, iaculis ` &&
`tellus. Proin nisi eros, tristique nec tortor quis, suscipit sodales dui.` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in sap.ui.layout
- Fix Flex - Vertical Direction — Shows a FixFlex control with a vertical layout.
- CSSGrid — CSSGrid example for page layout.
- Splitter Layout - 2 areas — Simple splitter example with two content areas
- Dynamic Side Content — Attaches side content area which is next to the main content of the page on larger screen…
- Fullscreen – with toolbar — A form that uses Toolbars as Form header and FormContainer headers.
- Controlling Empty Spaces Within the Grid — Example of setting the gridAutoFlow property.
- Horizontal Layout — The Horizontal Layout control is a simple way to align multiple controls horizontally. By…
- Grid - Using GridData — Take advantage of sap.ui.layout.GridData to control the appearance of individual Grid chi…
- Vertical Layout — The Vertical Layout control is a simple way to align multiple controls vertically. If you…
- Fullscreen – with toolbar — A SimpleForm that uses Toolbars as Form header and FormContainer headers.
- Responsive Splitter — ResponsiveSplitter is used to visually divide the content of its parent. It consists of P…
- Grid - Info Layout — You can use the Grid control to make responsive table-free layouts; here we are using a d…
On this page