Grid - Info Layout
You can use the Grid control to make responsive table-free layouts; here we are using a default indent and span, and specifying the Small settings such that the image and text will stack on a small display.
Z2UI5_CL_SMPC_APP_194
Controls
sap.ui.layout
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_194- Source file
z2ui5_cl_smpc_app_194.clas.abap↗- Library
- sap.ui.layout
- UI5 entity
sap.ui.layout.Grid- Demo kit sample
sap.ui.layout.sample.GridInfo- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: grid, sap.ui.layout, gridinfo, image, griddata, vbox, text
Controls it builds
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_194.clas.abap — 175 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords grid sap.ui.layout gridinfo image griddata vbox text
" @summary You can use the Grid control to make responsive table-free layouts; here we are using a default indent and span, and specifying the Small settings such that the image and text will stack on a small display.
CLASS z2ui5_cl_smpc_app_194 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_person,
firstname TYPE string,
lastname TYPE string,
title TYPE string,
contactpicurl TYPE string,
description TYPE string,
END OF ty_s_person.
DATA t_persons TYPE STANDARD TABLE OF ty_s_person WITH EMPTY KEY.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_194 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
model_init( ).
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` v = `sap.m`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->ele( n = `Grid` ns = `l`
)->a( n = `binding` v = client->_bind( t_persons )
)->a( n = `class` v = `sapUiSmallMarginTop`
)->a( n = `hSpacing` v = `2`
)->a( n = `defaultSpan` v = `L6 M6 S10`
)->ele( n = `content` ns = `l`
)->ele( `Image`
)->a( n = `src` v = `{0/CONTACTPICURL}`
)->a( n = `width` v = `100%`
)->ele( `layoutData`
)->tag( n = `GridData` ns = `l`
)->a( n = `span` v = `L3 M3 S8`
)->a( n = `linebreakL` v = `true`
)->a( n = `linebreakM` v = `true`
)->a( n = `linebreakS` v = `true`
)->end(
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `{0/FIRSTNAME} {0/LASTNAME}`
)->a( n = `class` v = `nameTitle`
)->tag( `Text`
)->a( n = `text` v = `{0/DESCRIPTION}`
)->end(
)->ele( `Image`
)->a( n = `src` v = `{1/CONTACTPICURL}`
)->a( n = `width` v = `100%`
)->ele( `layoutData`
)->tag( n = `GridData` ns = `l`
)->a( n = `span` v = `L3 M3 S8`
)->a( n = `linebreakL` v = `true`
)->a( n = `linebreakM` v = `true`
)->a( n = `linebreakS` v = `true`
)->end(
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `{1/FIRSTNAME} {1/LASTNAME}`
)->a( n = `class` v = `nameTitle`
)->tag( `Text`
)->a( n = `text` v = `{1/DESCRIPTION}`
)->end(
)->ele( `Image`
)->a( n = `src` v = `{2/CONTACTPICURL}`
)->a( n = `width` v = `100%`
)->ele( `layoutData`
)->tag( n = `GridData` ns = `l`
)->a( n = `span` v = `L3 M3 S8`
)->a( n = `linebreakL` v = `true`
)->a( n = `linebreakM` v = `true`
)->a( n = `linebreakS` v = `true`
)->end(
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `{2/FIRSTNAME} {2/LASTNAME}`
)->a( n = `class` v = `nameTitle`
)->tag( `Text`
)->a( n = `text` v = `{2/DESCRIPTION}` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD model_init.
" Data of the mock model sap/ui/layout/sample/GridInfo/persons.json used by the original sample
t_persons = VALUE #(
( firstname = `George`
lastname = `Washington`
title = `1st U.S. President`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/2/25/George_Washington_as_CIC_of_the_Continental_Army_bust.jpg`
description = `George Washington was the first President of the United States, the commander-in-chief of the Continental Army during the American Revolutionary War, and one of the Founding Fathers of the United States.` )
( firstname = `Alexandrina`
lastname = `Victoria`
title = `Former Queen regnant`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/a/aa/Dronning_victoria.jpg`
description = `Queen Victoria was the monarch of the United Kingdom of Great Britain and Ireland from 20 June 1837 until her death. From 1 May 1876, she used the additional title of Empress of India.` )
( firstname = `Friedrich`
lastname = `Der Große`
title = `King of Prussia 1740-1786`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/f/fc/Frederic_II_de_prusse.jpg`
description = `Frederick II was King in Prussia of the Hohenzollern dynasty. He is best known for his brilliance in military campaigning and ` &&
`organization of Prussian armies. He became known as Frederick the Great and was nicknamed Der Alte Fritz.` )
( firstname = `Agnes`
lastname = `Teresa`
title = `Mother Teresa`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/6/6e/The_Saint_Mother_Teresa.jpg`
description = `Mother Teresa (26 August 1910 – 5 September 1997), was an Albanian born, Indian Roman Catholic Religious Sister. She founded the ` &&
`Missionaries of Charity, a Roman Catholic religious congregation, which in 2012 consisted of over 4,500 sisters and is active in 133 countries.` )
( firstname = `Sigmund`
lastname = `Freud`
title = `Neurologist`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/6/69/Sigmund_Freud_Anciano.jpg`
description = `Sigmund Freud was an Austrian neurologist who became known as the founding father of psychoanalysis.` )
( firstname = `Christopher`
lastname = `Columbus`
title = `Explorer`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/0/06/CristobalColon.jpg`
description = `Christopher Columbus was an Italian explorer, navigator, and colonizer, born in the Republic of Genoa, in what is today northwestern Italy.` )
( firstname = `Winston`
lastname = `Churchill`
title = `Former Prime Minister of the United Kingdom`
contactpicurl = `http://upload.wikimedia.org/wikipedia/commons/3/35/Churchill_portrait_NYP_45063.jpg`
description = `Sir Winston Leonard Spencer-Churchill, KG, OM, CH, TD, DL, FRS, Hon. RA was a British politician who was Prime Minister of the United Kingdom from 1940 to 1945 and again from 1951 to 1955.` ) ).
ENDMETHOD.
ENDCLASS.
More in sap.ui.layout
- 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…
- Block Layout — The BlockLayout is intended to be used with rows and cells. The cells have predefined wid…
- Fix Flex - Vertical Direction with minFlexSize — Shows a FixFlex control where the minFlexSize is set to 400px.
- Fix Flex - Horizontal Direction — Shows a FixFlex control with a horizontal layout.
- Block Layout with links as titles — The BlockLayout Cells can have links as titles. The link text overwrites the title text.
- Grid - Features Demo — The major layout features of the Grid control are shown in this example. Features like in…
- Nested Splitter Layouts - 7 Areas — Nested Splitter example with 7 content areas
On this page