<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="table.controller.View1" displayBlock="true">
<Shell id="shell">
<App id="app">
<pages>
<Page id="page" title="{i18n>title}">
<content>
<FlexBox direction="Column" class="sapUiLargeMargin">
<SearchField liveChange=".onSearch" width="50%"/>
<Table id="__Table" items="{path: 'oNWModel>/Products'}" growing="true" growingThreshold="10" enableBusyIndicator="true" class="sapUiSmallMarginTopBottom" >
<columns>
<Column hAlign="Center">
<FlexBox alignItems="Center">
<Text text="Id"/>
<Button icon="sap-icon://copy" press="onCopy" tooltip="Copy Data" type="Transparent" class="sapUiTinyMarginBegin" />
</FlexBox>
</Column>
<Column >
<FlexBox alignItems="Center">
<Text text="Name"/>
<Button icon="sap-icon://copy" press="onCopy" tooltip="Copy Data" type="Transparent" class="sapUiTinyMarginBegin"/>
</FlexBox>
</Column>
<Column hAlign="Center">
<FlexBox alignItems="Center">
<Text text="Price"/>
<Button icon="sap-icon://copy" press="onCopy" tooltip="Copy Data" type="Transparent" class="sapUiTinyMarginBegin"/>
</FlexBox>
</Column>
</columns>
<items>
<ColumnListItem vAlign="Middle">
<cells>
<Text text="{oNWModel>ProductID}"/>
<Text text="{oNWModel>ProductName}"/>
<Text text="{oNWModel>UnitPrice}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</FlexBox>
</content>
</Page>
</pages>
</App>
</Shell>
</mvc:View>
onCopy: function (oEvent) {
//Fetch the Column from where the event is triggered
var oCol = oEvent.getSource().getParent().getParent();
// Fetch the Table properties
var oTable = oCol.getTable();
//Get the items of the table
var oItems = oTable.getItems();
//You need the index of the column to get the exact cell of the item
var iIndex = oCol.getIndex() - 1;
//Column separtor to seggregate the data in table
var colSeparator = '\n';
var sCopy = "";
oItems.forEach(oItem => {
var oCell = oItem.getCells()[iIndex];
var sText = oCell.getText();
sCopy += sText + colSeparator;
});
//Copy the data to the clipboard
navigator.clipboard.writeText(sCopy).then(function () {
MessageToast.show("Column Copied");
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
40 | |
25 | |
17 | |
13 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 |