In this blog, I am going to explain Customizing the existing Default Column with Formatter and Creating Entire New Custom Column in SmartTable Control.
{
"path": "/Northwind",
"target": {
"type": "destination",
"name": "Northwind"
},
"description": "Northwind odata services"
}
"sap.app": {
"dataSources": {
"mainService": {
"uri": "/Northwind/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
},
"sap.ui5": {
"models": {
"": {
"dataSource": "mainService",
"preload": true
}
},
}
<content>
<smartTable:SmartTable entitySet="Products" tableType="ResponsiveTable" showRowCount="true" useExportToExcel="false" useVariantManagement="false" useTablePersonalisation="true" demandPopin="true" enableAutoBinding="true" header="Line Items" placeToolbarInTable="true" persistencyKey="SmartTablePKey" initiallyVisibleFields="ProductName,QuantityPerUnit,UnitPrice,UnitsOnOrder,DisContinued, UnitsInStock” >
<Table sticky="ColumnHeaders,HeaderToolbar">
<columns>
<Column>
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "UnitsInStock", "leadingProperty": "UnitsInStock", "columnIndex": 5}'/>
</customData>
<Text text="{i18n>UnitsInStock}"></Text>
</Column>
</columns>
<items>
<ColumnListItem>
<ObjectStatus text="{UnitsInStock}" state="{path: 'UnitsInStock', formatter: '.formatter.StockStatus'}"></ObjectStatus>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
</content>
sap.ui.define(function () {
return {
StockStatus: function (iNo) {
if (iNo < 50) {
return sap.ui.core.ValueState.Error;
} else {
return sap.ui.core.ValueState.Success;
}
}
};
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
"../model/formatter"
], function (Controller, formatter) {
"use strict";
return Controller.extend("com.data.BindingData.controller.BindingData", {
formatter: formatter,
});
});
<content>
<smartTable:SmartTable class="sapUiSizeCompact " editable="false" placeToolbarInTable="true" enableAutoBinding="true" entitySet="Products" header="Products" showFullScreenButton="true" showRowCount="true" tableType="ResponsiveTable" demandPopin="false" useExportToExcel="false" useTablePersonalisation="true" useVariantManagement="false"
initiallyVisibleFields="SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder, ReorderLevel,Discontinued" requestAtLeastFields="ProductID,ProductName" persistencyKey="SmartTablePKey">
<Table sticky="ColumnHeaders,HeaderToolbar">
<columns>
<Column>
<Label text="Product ID-Name"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier text="{ProductID} -- {ProductName}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
</content>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 | |
4 |