this.getView().getContent()[0].getSections()[0].getSubSections()[0].getBlocks()[0].getContent()[0].setLayout(new sap.ui.comp.smartform
.Layout({
columnsXL: 3,
columnsL: 3,
columnsM: 3,
labelSpanXL: 2,
labelSpanL: 4,
labelSpanM: 5,
labelSpanS: 6,
gridDataSpan: "XL2 L3 M3 S6",
emptySpanXL: 0,
emptySpanL: 0,
emptySpanM: 0,
emptySpanS: 0
}));
this.byId("idSmartTable").getTable().attachEvent("updateFinished", function (data) {
var items = this.byId("idSmartTable").getTable().getItems().length;
var tableItems = this.byId("idSmartTable").getTable().getItems();
for (var i = 0; i < items; i++) {
this.byId("idSmartTable").getTable().getItems()[i].setType('Navigation');
this.byId("idSmartTable").getTable().getItems()[i].attachPress(this.onPressCases, this);
}
this.extensionAPI.attachPageDataLoaded(this.onDetailsLoaded, this);
onDetailsLoaded: function (event) {
var sPath = event.context.sPath // has the context path
var contextObj = event.context.getObject();//contains the context Object and has all the properties bound in the list report Item
}
this.getView().byId("id::Table")
<Record Type="UI.DataField">
<PropertyValue Property="Value">
<Apply Function="odata.concat">
<String>Current Tier</String>
<String></String>
<String>:</String>
<String></String>
<Path>tierlevel</Path>
</Apply>
</PropertyValue>
<PropertyValue Property="Label" String="{@i18n>CURRENT_TIER}"/>
</Record>
filterBar.attachInitialized(this.onInitSmartFilter, this);
smartTable.applyVariant({});
sap.ui.getCore().getConfiguration().getFormatSettings().setDatePattern("medium","MMM d,yyyy");
var currListItemPath = currentListItem.getBindingContextPath(); that.getView().getModel().resetChanges([currListItemPath]);
if(oModel.hasPendingChanges())
{
oModel.resetChanges();
}
In Manifest.json inside card settings
"customParams": "getParameters"
In Custom Controller
getParameters: function (oNavigateParams, oSelectionVariantParams) {
// to get the select option property names, make use of this to check what values are available to modify
var navParams = Object.keys(oNavigateParams);
var aCustomSelectionVariant = [];
/// logic to remove Filter1
/// assigning empty values to Filter1 and Filter2, with ignoreEmptyString as true, this will be removed from the Selection Variant
var filter1= {
path: "filter1",
operator: "EQ",
value1: oNavigateParams['FIlter1'],
value2: null,
sign: "I"
};
/// logic to remove Filter1
aCustomSelectionVariant.push(filter1);
return {
selectionVariant: aCustomSelectionVariant,
ignoreEmptyString: true
};
},
smartfb.getControlByKey("control1").attachValueHelpRequest(this.dialogOpened, this);
dislogOpened:function(event)
{
var control = event.getSource();
var t = this;
setTimeout(function () {
control.getDependents()[0].setBasicSearchText('');
}, 100);
}
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(this);
var oParseNavigationPromise = oNavigationHandler.parseNavigation();
oParseNavigationPromise.done(function (oAppData, oStartupParameters, sNavType) {
oSmartFilter.setDataSuiteFormat(oAppData.selectionVariant, true);
}.bind(this));
}
oSmartFilter.fireSearch();
And lo! all yur filters are set just like in list report!
Say you have name,DOB,COmpany as keys of the current entity set in the object page
you can get them as key value pairs
this.extensionAPI.getNavigationController().getCurrentKeys()
will give you an array. It will contain a string like "name='abc',DOB='12/03/91',COmpany='def'"
14.Removing Scale Factor /Rounding off in OVP card header/line items
Try to change config settings of the app
sap.ui.getCore().getConfiguration().setFormatLocale("standard");
15. Let the list report app know which card are you coming from
When you want to navigate to a particular section in the object page based on the card from which your are come from in dashboard you can add a parameters to the shellHash.
Note: The position of this parameter varies if its a standard or custom card.In a standard card we should ensure it doesn't mix up with the context parameters and messes up the URL.
Check the difference here in the 'from' parameter.
Standard Card: "SemanticObject-action&/someurlparameters?from='card1'
Custom card:"SemanticObject-action?from='card2'&/someurlparameters
16.Navigate to another app(that has redirection to another system configured in lpd_cust) in new tab from an OVP standard list card
The newer versions of sapui5 does not navigate in new tab from a list card if its navigation with datafieldforntentbasednavigation. to tweak this, use datafieldwithurl in docustomnavigation method , create hash using hrefforexternal and in the url concatenate "/sap/bc/ui2/flp"+hash and Lo it opens in new tab
filterBar.addFilterGroupItem(new sap.ui.comp.filterbar.FilterGroupItem({
groupName: "grp1",
label: "Custom label",
partOfCurrentVariant: true,
visibleInFilterBar: true,
name: "custLbl",
control: new sap.m.MenuButton({
menu: menu
})
}));
event.getSource()._getFilterGroupItemByGroupName('custLbl').getControl()
var mempageloaded = this._memPageDataLoaded.bind(this); this.extensionAPI.attachPageDataLoaded(mempageloaded);
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form"
xmlns:smartTable="sap.ui.comp.smarttable" xmlns:sf="sap.ui.comp.smartfield" xmlns:form="sap.ui.comp.smartform">
<Dialog id="onlineavailabilityid2" title="{@i18n>List_to_Search}" resizable="true" contentWidth="40%" afterClose="dialogAfterclose">
<content>
<!--BTCCECSC-234-->
<f:SimpleForm id="form" editable="true">
<Label labelFor="idStore" text="Select Store" design="Bold"></Label>
<sf:SmartField value="{property1}" id="idStore" mandatory="false" entitySet="entityset">
<sf:layoutData>
<l:GridData spanL="1" spanM="1" spanS="1"/>
</sf:layoutData>
<sf:configuration>
<sf:Configuration preventInitialDataFetchInValueHelpDialog="true"/>
</sf:configuration>
</sf:SmartField>
</f:SimpleForm>
SmartForm
<core:FragmentDefinition xmlns:commons="sap.ui.commons" xmlns:core="sap.ui.core" xmlns:form="sap.ui.layout.form" xmlns:l="sap.ui.layout"
xmlns:sfi="sap.ui.comp.smartfield" xmlns:sfo="sap.ui.comp.smartform" xmlns:table="sap.ui.table"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1" xmlns:uxap="sap.uxap" xmlns="sap.m"
xmlns:f="sap.ui.layout.form" xmlns:smartForm="sap.ui.comp.smartform" xmlns:smartField="sap.ui.comp.smartfield">
<smartForm:SmartForm id="smartFormGeneral" editable="true">
<smartForm:Group id="Generalinfoid">
<smartForm:GroupElement label="{@i18n>text}">
<sf:SmartField value="{property1}" id="idStore" mandatory="false" entitySet="entitysetname">
<sf:layoutData>
<l:GridData spanL="1" spanM="1" spanS="1"/>
</sf:layoutData>
<sf:configuration>
<sf:Configuration preventInitialDataFetchInValueHelpDialog="true"/>
</sf:configuration>
</sf:SmartField>
</smartForm:GroupElement>
/resources/sap/suite/ui/generic/template/lib/i18n/i18n.properties
/resources/sap/suite/ui/generic/template/ListReport/i18n/i18n.properties
var table=this.getView().byId("table") // this is how you access the table in ALP
var columns=table.getColumns();
for(var key in columns)
{
this.getView().byId("table").getColumns()[key].showIfGrouped(false);
}
var oControlConfigs = this.getView().byId("SmartFilterBar").getControlConfiguration();
for (var key in oControlConfigs) {
if (oControlConfigs[key].getKey().match(/employee/gi)) {
oControlConfigs[key].setControlType(sap.ui.comp.smartfilterbar.ControlType.dropDownList);
}
}
<List noDataText="{@i18n>noFields}"
items="{path: 'disputes>entityset',factory:'.createContent',templateShareable: false}"></List>
Create fragments for the two different types of templates that you want to determine at runtime
say- one fragment for edit ( different fields-input,checkbox, select etc)
one fragment for display ( all text fields)
Controller code
createContent: function(sId, oContext) {
var oUIControl;
// Decide based on the data which dependent to clone
if (oContext.getProperty("UnitsInStock") === 0 && oContext.getProperty("Discontinued")) {
// The item is discontinued, so use a StandardListItem
oUIControl = this.byId("productSimple").clone(sId);
} else {
// The item is available, so we will create an ObjectListItem
oUIControl = this.byId("productExtended").clone(sId);
// The item is temporarily out of stock, so we will add a status
if (oContext.getProperty("UnitsInStock") < 1) {
oUIControl.addAttribute(new ObjectAttribute({
text : {
path: "i18n>outOfStock"
}
}));
}
}
return oUIControl;
}
<core:FragmentDefinition
xmlns="sap.ui.comp.valuehelpdialog"
xmlns:core="sap.ui.core">
<ValueHelpDialog
title="a value"
ok=".onValueHelpOkPress"
cancel=".onValueHelpCancelPress"
afterClose=".onValueHelpAfterClose"
key="Value"
descriptionKey="Description"
supportMultiselect="false"
tokenDisplayBehaviour="descriptionOnly"
>
</ValueHelpDialog>
</core:FragmentDefinition>
onValueHelpRequest: function (event) {
this.vhpSource = event.getSource();
var vhpSet = event.getSource().getBinding("suggestionItems").sPath;
this._oValueHelpDialog = new sap.ui.xmlfragment("namespace.fragment.ValueHelpDialog", this);
var filters = event.getSource().getBinding("suggestionItems").aApplicationFilters;
this.getView().addDependent(this._oValueHelpDialog);
this._oValueHelpDialog.getTableAsync().then(function (oTable) {
oTable.bindAggregation("rows", {
path: vhpSet,
filters: filters
});
var oTemplate = new sap.ui.table.Column({
label: new sap.m.Label({
text: "Description"
}),
template: new sap.m.Text({
text: "{Description}"
})
});
if (oTable.bindColumns) {
oTable.addColumn(oTemplate);
}
this._oValueHelpDialog.update();
}.bind(this));
this._oValueHelpDialog.open();
},
<core:Item key="{Code}" core:require="{ format: 'znamespace/ext/models/format' }" enabled="{parts:[{path:'Enabled'},{path:'enabled2'}],formatter: 'znamespace.ext.models.format.formatEnabled'}"/>
sap.ui.define(function () {
return {
formatEnabled: function (enabled, enabled2) {
var flag = this.getParent().getBindingContext().getObject().someflag; //this references the current control
if (flag) {
return enabled2;
} else {
return enabled;
}
}
};
}, /*expose globally*/ true);
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
add this in your control
<Select app:somedata="{datafrombackend}">
access in controller
this.getView().byId("select").data().somedata
30. Get binding context of custom facets
in Smart templates when we have custom fragments, they are automatically bound to the view and the binding context is not exposed. Say we wanrt to refresh only that aprticular facet we could sue the bind element for it
var sPath=this.getView().getBindingContext().sPath;
this.getView().byId("customfacetid").bindElement(sPath, {
expand: "navigationproperty"
});
32.Using text annotation for a property. Works only for multiselect fields( for single select only the code displays)
<Annotations Target="Metadata.VHPName/City">
<Annotation Term="Common.Text" Path="CityName">
<Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
</Annotation>
<Annotations Target="Metadata.UserDetails/StoreId">
<Annotation Term="Analytics.Dimension" Bool="true"/>
35. Set filter data to multitoken field in smartfilterbar
var filterdata = this.getView().byId("listReportFilter").getFilterData();
filterdata["Status"] = { // here your value help field
"items": [{
key: somevalue// Pass the key here
}]
};
this.getView().byId("listReportFilter").setFilterData(filterdata);
You can also directly set filterdata by setting the JSON
36.Read data from a smarttable
Since the smarttable directly reads data from odata it is usually not possibly to read the data bound to the table unless we access the inner table.In this case "events parameter comes to the rescue
You can add change,datarequested,datareceived,attachdatastatechange events to the beforerebindtable/beforerebindtableextension(if its a list report) method
onBeforeRebindTableExtension: function (event) {
event.getParameters()["bindingParams"].events = {
"dataRequested":function(er)
{
},
"dataReceived": function (ec) {
ec.getParameter("data") //this will give the table resultset
}
37.CHange Nav from Responsive Table in object page
First make the responsive table in object page clikable. for this add an empty pages aggregation in the manifest and add cross navigation outbounds
under sap.app add this
"crossNavigation": {
"inbounds": {},
"outbounds": {
"WebUi": {
"semanticObject": "someobj",
"action": "display"
},
"to_Disputes4mOrderList": {
"semanticObject": "someobj1",
"action": "action"
}
}
}
add under object page
"ObjectPage|navprop": {
"navigationProperty": "navprop",
"entitySet": "navset",
"component": {
"name": "sap.suite.ui.generic.template.ObjectPage"
},
"pages": {
}
}
var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
var oUrlParsing = sap.ushell.Container.getService("URLParsing");
var semanticObject = oUrlParsing.splitHash(oUrlParsing.getHash(window.location.href));
if (semanticObject.appSpecificRoute) {
var listHash = semanticObject.shellPart;
this.extensionAPI.refreshAncestors(1);
new sap.ui.core.routing.HashChanger().setHash(listHash);
} else {
oCrossAppNavigator.toExternal({
target: {
shellHash: "#"
}
});
}
"SmartFormExtension|entityset|idofreferencefacet":
{
"type": "XML",
"className": "sap.ui.core.Fragment",
"fragmentName": "<fragmentpath>"
}
oEvent.getSource().getInnerControls()[0].onBeforeRenderingDropdown = function(e) {
if (sap.m.ComboBox.prototype.onBeforeRenderingDropdown) {
sap.m.ComboBox.prototype.onBeforeRenderingDropdown.apply(this, arguments);
}
// Your code...
};
var delay = function (elem, callback) {
var timeout = null;
elem.attachBrowserEvent("mouseover", function () {
timeout = setTimeout(callback, 1000);
});
elem.attachBrowserEvent("mouseout", function () {
// Clear any timers set to timeout
clearTimeout(timeout);
});
};
//call the above function to open popover
delay(control, function () {
//define what to happen during mouseover. here it opens a popover
popover.openBy(control);
});
Use it inside model for manifest.json
"": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "TwoWay",
"defaultCountMode": "Inline",
"serviceUrlParams":{
"sap-statistics":true
}
},
"dataSource": "mainService",
"preload": true
},
var oNavControl = this.extensionAPI.getNavigationController();
oNavControl.navigateExternal("outboundsnameinmanifest", {
param1: value,
preferredMode: "create"
});
"crossNavigation": {
"inbounds": {},
"outbounds": {
"outboundsnameinmanifest": {
"semanticObject": "zappname",
"action": "display"
}
in Destination app
"sap.ui.generic.app": {
"_version": "1.3.0",
"settings": {
"inboundParameters": {
"param1": {
"useForCreate": true
},
"sap-ushell-navmode":"explace"
var testLibs = new Promise(function (resolve, reject) { sap.ui.require(["sap/ui/thirdparty/require"], function () {
requirejs.config({
paths: {
"libs": ["//cdn-stage.libs.com"]
}
});
resolve();
});
});
testLibs.then(require(["libs"], function (libs) {
that.somefunction();
window.some pi.renderPrivateMode({
containerId: "abcd-scrollCont",
locale: "en-US",
siteId: "fgdgdfgfdgdfg",
identifier: "435gfdgdfgdfg",
contact: "test@test.com"
});
}));
sap.ui.loader.config( {
baseUrl: "../"
} );
var path = sap.ui.require.toUrl( "images/someimage.png" );
model.read( path,
{
urlParameters: {
"$select": "someprop",
},
formatterfunction: function ( propertypassedfromview) {
var t = this;
if ( propertypassedfromview) {
var context = this.getView().getBindingContext().getObject();
var model= this.getOwnerComponent().getModel( "somemodel" );
var path = sap.ui.require.toUrl( "NameSpace/ext/fragment/somefolder" ) + "/products.json"
<ObjectStatus class="sapUiTinyMarginEnd" text="{somemodel>BasePrice}{somemodel>Currency}" >
<customData>
<core:CustomData key="someproperty-available" value="{=String(${somemodel>someproperty} ==='0.00')}" writeToDom="true"/>
</customData>
</ObjectStatus>
in CSS FIle
div[data-red-price-available="true"] span {
text-decoration: line-through;
}
"sap.ui.generic.app": {
"_version": "1.3.0",
"settings": {
"flexibleColumnLayout": {
"defaultTwoColumnLayoutType": "TwoColumnsMidExpanded",
"defaultThreeColumnLayoutType": "ThreeColumnsEndExpanded"
}
},
getCustomAppStateDataExtension: function ( oCustomData ) {
//the content of the custom field will be stored in the app state, so that it can be restored later, for example after a back navigation.
//The developer has to ensure that the content of the field is stored in the object that is passed to this method.
var oCustomField = this.getView().byId( "somemultiinput" );
oCustomData.artDesc = [];
if ( oCustomField ) {
if ( oCustomField.getTokens() && oCustomField.getTokens().length > 0 ) {
oCustomField.getTokens().forEach( function ( oItem ) {
oCustomData.artDesc.push( {
text: oItem.getText(),
key: oItem.getKey()
} );
} );
}
}
return oCustomData;
},
restoreCustomAppStateDataExtension: function ( oCustomData ) {
//in order to restore the content of the custom field in the filter bar, for example after a back navigation,
//an object with the content is handed over to this method. Now the developer has to ensure that the content of the custom filter is set to the control
if ( oCustomData ) {
if ( oCustomData.artDesc ) {
var oInput = this.getView().byId( "somemultiinput" );
if ( oCustomData.artDesc && oCustomData.artDesc.length > 0 ) {
oInput.removeAllTokens();
oCustomData.artDesc.forEach( function ( oItem ) {
oInput.addToken( new sap.m.Token( {
text: oItem.text,
key: oItem.key
} ) );
} );
}
}
}
},
<f:GridList id="gridList" headerText="{i18n>Products}" items="{ path: '/someset' , suspended: true, parameters: {count: true,groupId:'groupIdsomething'}}" >
this.getOwnerComponent().getService( "ShellUIService" ).then( function ( oShellService ) {
oShellService.setBackNavigation( function () { that.handleCancel(); } );
} );
handleCancel:function(event)
{
//this method will be triggered on pressing back
}
"chartSettings": {
"showDataLabel": true,
"enableStableColors": true,
"dimensionSettings": {
"CostElement": { // Dimension Name
"400020": { // Dimension Value
"color":"red",
"legendIndex":0
},
"421000": {
"color":"sapUiChartPaletteSemanticNeutral",
"legendIndex":1
},
"417900": {
"color":"blue",
"legendIndex":2
}
},
“Customerâ€: {
"C000013": {
"color": "red",
"legendIndex": 0
},
"C000085": {
"color": "blue",
"legendIndex": 0
},
},
"default" : {
"color": "green"
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 |