onPress-Event in SmartTables - sapui5

In a normal list we have sth like this
<List noDataText="---" id="__list0" items="{model>/Orders}">
<items>
<StandardListItem type="Navigation" title="{model>OrderName}" press="onPress" />
</items>
</List>
So we set the press-Event in the Items, but if we have a SmartTable we do not have the inner
<StandardListItem type="Navigation" title="{model>OrderName}" press="onPress" />
I just have:
<sap.ui.comp.smarttable:SmartTable xmlns:sap.ui.comp.smarttable="sap.ui.comp.smarttable"
height="100%"
width="100%"
direction="Column"
fitContainer="true"
tableType="ResponsiveTable"
header="Smart Table"
enableAutoBinding="true"
id="__table0"
entitySet="Datas"/>
//Not the same Model in this case
How can I set an onPress event for the columns?
Thank you very much for your Help.

Related

UI5: SmartTable Personalisation/Variant Management Error

Hello Experts, I'm unsure why this error (pictured) is appearing. As far as I know, SmartTable should be able to take care of everything to do with variant management, right? In my controller, I dont have any code pertaining to variant management.
Here is the below code for my smartTable:
<smartTable:SmartTable id="smartTable" entitySet="Z9NRS_REQUESTSet" tableType="ResponsiveTable"
useExportToExcel="true" beforeExport="onBeforeExport" demandPopin="true" useVariantManagement="true" useTablePersonalisation="true"
header="Manage Requests" showRowCount="true" persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true"
class="sapUiResponsiveContentPadding" initiallyVisibleFields="ZNRS_REQUEST,ZREQUESTOR_NAME,ZPRODUCT_FAMILY,ZOEM,ZTIER,ZCUSTOMER_PN,ZMATERIAL_NO,ZSTATUS_DESC,ZCONNECTOR_CONFIG" >
<smartTable:customToolbar>
<OverflowToolbar>
<ToolbarSpacer/>
<!--<Button icon="sap-icon://settings" type="Accept" />-->
</OverflowToolbar>
</smartTable:customToolbar>
<Table mode="SingleSelectMaster" selectionChange="onPress" inset="false" >
<columns>
<Column>
<Text text="Status"/>
<customData>
<!--p13nData is a keyword that links smartTable to this and let it identify this custom column-->
<core:CustomData key="p13nData" value='\{"columnKey":"ZSTATUS_DESC",
"leadingProperty":"ZSTATUS_DESC", "sortProperty":"ZSTATUS_DESC",
"filterProperty":"ZSTATUS_DESC", "columnIndex":7}' />
</customData>
</Column>
</columns>
<items>
<ColumnListItem >
<!--<ObjectStatus text="{ZSTATUS_DESC}" />-->
<ObjectStatus text="{ZSTATUS_DESC}" state="{path:'ZOVERALL_STATUS', formatter:'.formatter.DrawingStatus'}" />
</ColumnListItem>
</items>
</Table>
<!-- layout data used to make the table growing but the filter bar fixed -->
<smartTable:layoutData>
<FlexItemData growFactor="1" baseSize="0%"/>
</smartTable:layoutData>
</smartTable:SmartTable>
When I deployed and tested variant management it worked. But in FLPSandbox it wasn't working, so I guess it had to do with the app's access to some backend system(?)

SAPUI5 table in list

I have a view:
<List
items="{data>/Stages}">
<CustomListItem>
<Panel>
<headerToolbar>
<Toolbar>
<content>
<Button
visible="{= ${data>/Stages/length} > 1}" />
</content>
</Toolbar>
</headerToolbar>
<content>
<Table
growing="true"
growingScrollToLoad="false"
items="{
path: 'data>FieldWorks',
templateShareable: true
}"
class="blueTable originTable techTable">
<columns>
<Column
visible="true"
vAlign="Middle"
width="15px" />
</columns>
<items>
<ColumnListItem>
<cells>
<core:Icon
visible="{ ???}"
src="sap-icon://customfont/moving"
size="2.1rem"
color="#14c6c9" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Panel>
</CustomListItem>
</List>
I have a model (example):
data: {
Stages: [{
FieldWorks: [{}, ....]
}, .....]
}
I hide my button (in my toolBar) by expression binding as you can see.
What is the best way to hide my Icon (in CustomListItem) by condition FieldWorks.length > 1
If you are using a JSON Model just add boolean property to your JSONModel to the FieldWorks entity and bind the visible property to it. Then one time you have to set it when data is loaded or created and that's it.
You can define a new property in your json Model under the FieldWorks property in order to bind the visibility of the icon.
you can use Object.defineProperty (SPEC MDN) to define your calculated new property.

How to put table of UI5 smarttable inside of a scrollbar?

I have a smarttable with custom toolbar and a table inside.
Now I want to put just the table and not the whole smarttable inside of a scroll container. But if I do that then data is not bound to the inner table anymore.
<smartTable:SmartTable id="_0" entitySet="ProjectOrganisationHeadSet" tableBindingPath="/ProjectOrganisationHeadSet"
tableType="ResponsiveTable" smartFilterId="prorgrelWorklistFilterBarId" showFullScreenButton="true" useVariantManagement="false"
enableAutoBinding="true" ignoredFields="" beforeRebindTable="handleBeforeRebindTable" app:myStatus="EDIT"
initiallyVisibleFields="ProjectorgaId,Title,....">
<smartTable:customToolbar>
<OverflowToolbar design="Transparent">
<ToolbarSpacer/>
<Button type="Transparent" press="onCreateBtnPress" icon="sap-icon://add"/>
</OverflowToolbar>
</smartTable:customToolbar>
<ScrollContainer id="__scrollContainer0" horizontal="true" vertical="true">
<Table id="table0" mode="None" busyIndicatorDelay="0">
<items>
<ColumnListItem type="Navigation" press="onPress">
<cells>
<Text text="{path: 'ProjectorgaId', formatter: '.formatter.intNumber'}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</ScrollContainer>
While it must show 40 rows, it shows nothing. If I remove the scrollcontainer all rows will be shown.

JSONModel bound to List in a dialog is showing last object of the json array for all rows of the list

I can't find the problem in my code. The number of rows is always correct, but it only shows the values of the last object in the array of the binding. I'm using the correct aggregation <items> so that's not the issue. Maybe (I hope) I'm just overlooking something.
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<Dialog title="{i18n>selectionTitle}" horizontalScrolling="false">
<beginButton>
<Button text="{i18n>closeSelectionButton}" press="handleCloseSelectedTrainings"/>
</beginButton>
<endButton>
<Button type="Accept" text="{i18n>submitSelectionButton}" press="handleSubmitSelectedTrainings"/>
</endButton>
<content>
<List noDataText="Empty" items="{selectedTrainings>/}" mode="Delete" delete="handleDeleteSelectionItem">
<items>
<CustomListItem >
<HBox>
<core:Icon size="2rem" src="{icon}" class="sapUiSmallMarginBegin sapUiSmallMarginTopBottom"/>
<VBox class="sapUiSmallMarginBegin sapUiSmallMarginTopBottom">
<Text text="{Title}" />
<Label text="{Type} {= ${Begda} ? ${Begda}.toLocaleDateString() : '' }"/>
<HBox>
<CheckBox text="{i18n>selectionMgrApproved}" selected="{Approved}" />
</HBox>
</VBox>
</HBox>
</CustomListItem>
</items>
</List>
</content>
</Dialog>
You are using named model selectedTrainings for items bindings and you forgot to put a model name into CustomListItem elements. Put a model name into bindings like this:
<Text text="{selectedTrainings>Title}" />

Unable to trigger Click Even from List inside TileContainer SAPUI5

I have a list inside Tile container.Direct list is working Okay, but inside the tile container I'm unable to trigger itemPress event. the code is as below
<TileContainer id="container" tileDelete="handleTileDelete">
<CustomTile class="sapMTile customTile sapMPointer ">
<ScrollContainer height="100%" width="100%" vertical="true" focusable="true">
<l:VerticalLayout class=" sapUiContentPadding" width="100%">
<l:content>
<FlexBox>
<List items="{/activeRules}" headerText="" **itemPress="onActiveRulesListItemPress"** growing="true" growingThreshold="3">
<CustomListItem>
<HBox>
<VBox class="sapUiSmallMarginBegin sapUiSmallMarginTopBottom">
<Text class="flexTilebar" text="{name}"/>
<FlexBox class="flexTilebar">
<micro:StackedBarMicroChart size="Responsive" maxValue="{/maxNumberOfInvocztions}">
<micro:bars>
<micro:StackedBarMicroChartBar valueColor="Neutral" value="{numberOfInvocations}"/>
</micro:bars>
</micro:StackedBarMicroChart>
</FlexBox>
<FlexBox class="flexTilebar">
<micro:StackedBarMicroChart bars="{scheduledServiceInvocations}" maxValue="{/maxScheduleCount}" size="Responsive">
<micro:bars>
<micro:StackedBarMicroChartBar value="{scheduleCount}"/>
</micro:bars>
</micro:StackedBarMicroChart>
</FlexBox>
</VBox>
</HBox>
</CustomListItem>
</List>
</FlexBox>
</l:content>
</l:VerticalLayout>
</ScrollContainer>
</CustomTile>
</TileContainer>
Set type="Navigation" in customListItem Because CustomListItem inherits from ListItemBase
Have you tried to set the type property in CustomListItem as its default value is Inactive.
See ListBase documentation:
Fires when an item is pressed unless the item's type property is Inactive.