Reputation: 1133
I would like to have a delete icon in a label of a column of sap.ui.table.TreeTable
, to prevent an extra column for such.
I would like to put the icon right of the description, associated with an onPress
Event to delete this row.
I tried to put the icon within the <t:template>
aggregation. Would this be possible? Corresponding part of code of XML-view is as follows:
<t:TreeTable id="tree">
<t:columns>
<t:Column>
<t:label>
<Label text="{i18n>TREE_NAME_LABEL}"/>
</t:label>
<t:template>
<Label text="{TREE_DESCRIPTION}" />
</t:template>
</t:Column>
</t:columns>
</t:TreeTable>
Upvotes: 2
Views: 3563
Reputation: 18044
As of 1.45, we can assign actions for each row declaratively via the table's aggregation rowActionTemplate
. Currently, the following action types are available:
"Delete"
"Navigation"
"Custom"
with e.g. a custom icon
and a custom text
in the assigned RowActionItem
.In your case, it would be something like this:
<table:TreeTable xmlns:table="sap.ui.table" id="tree" rowActionCount="1">
<table:columns>
<!-- ... -->
</table:columns>
<table:rowActionTemplate>
<table:RowAction>
<table:RowActionItem
type="Delelte"
press=".onDelete"
/>
</table:RowAction>
</table:rowActionTemplate>
</table:TreeTable>
Ensure to set the table's property rowActionCount
which is required to render a certain number of actions initially without the user having to click on a … button.
Name Default value Description rowActionCount
0
Number of row actions made visible which determines the width of the row action column. The values 0
,1
and2
are possible.
The row action template needs to be reassigned every time its property or aggregation has changed.
Name Cardinality Type Description rowActionTemplate
0..1 sap.ui.table.RowAction [...] Each time the template's properties or aggregations are changed, the template has to be applied again via setRowActionTemplate
[...].
sap.ui.table.RowAction
sap.ui.table.RowActionItem
sap.ui.table.Table
Upvotes: 2