cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically hide a column in a table inside a FE Object Page using RAP and OData v4?

Andreas_M
Explorer
2,090

Dear community,

I couldn't find any solution to hide a column dynamically in a table inside an Fiori Elements Object Page with RAP and OData v4.

One solution I tried was to add a custom column in the manifest und to use expression binding, but that's not working.

 "controlConfiguration": { 
"_Mean/@com.sap.vocabularies.UI.v1.LineItem": { "columns": { "CustomColumnOnObjectPage": { "header": "CustomColumn", "template": "...", "availability": "{= ${CustomType} === '2' ? 'Hidden' : 'Adaption' }", "width": "10em" } } } }

Hiding fields in the object page is working with SADL and Virtual Elements but for columns in a table I didn't find a way.

I hope anyone know how to solve this without any big workarounds.

Thanks for your help.

Best regards

Andreas

View Entire Topic
Marian_Zeis
Active Contributor

Seems like you need to extend the controller.

I used this example

https://ui5.sap.com/test-resources/sap/fe/core/fpmExplorer/index.html#/controllerExtensions/basicExt...


Some rough code could look like this:

onAfterRendering () {
				    console.log("test")
				    this.getView().byId("sap.fe.core.fpmExplorer::Default--fe::table::_Child::LineItem-innerTable").getModel().attachDataReceived(function(event){
				        console.log("reveived")
				        debugger;
				        const id = event.getSource().getBoundContext().getObject().ID
				        if(id === 1){
				            this.getView().byId("sap.fe.core.fpmExplorer::Default--fe::table::_Child::LineItem-innerTable").removeColumn(1)
				        }
				        debugger;
				    })
				},
0 Kudos

Hello 20eed143c19f4b82bc4cf049916102cb

This answer solved my issue.I was missing "-innerTable". Thank you.

However, in my case inner table is not available in onAfterRendering, lineitem though is available.

	onAfterRendering: function () {
                var oTable = sap.ui.getCore().byId("claims::CLAIMS_V1ObjectPage--fe::table::_ITEM_V1::LineItem");
                //inner table should be available in a bit
				var intervalId = setInterval(function () {
					console.log('Custom onAfterRendering function', new Date());
                    var oInnerTable = sap.ui.getCore().byId("claims::CLAIMS_V1ObjectPage--fe::table::_ITEM_V1::LineItem-innerTable");
                    if (oInnerTable) {
					
						oInnerTable.setAlternateRowColors(true);
                        oInnerTable.setEnableColumnFreeze(true);
                        clearInterval(intervalId);
                    }
                }, 250);
            }

Console prints at least three times before inner table is available. OData v4 service

0 Kudos

better results with even delegate. Thanks again.

		onAfterRendering: function () {
				var oTable = sap.ui.getCore().byId("claims::CLAIMS_V1ObjectPage--fe::table::_ITEM_V1::LineItem");				
				oTable.addEventDelegate({
					onAfterRendering: function () {
						var oInnerTable = sap.ui.getCore().byId("claims::CLAIMS_V1ObjectPage--fe::table::_ITEM_V1::LineItem-innerTable");
						if (oInnerTable) {
							console.log('Custom onAfterRendering function', new Date());
							oInnerTable.setAlternateRowColors(true);
							oInnerTable.setEnableColumnFreeze(true);
						}
					}
				});
			}
Marian_Zeis
Active Contributor
0 Kudos

Happy to help. You can accept the answer if this was the best solution.

Thanks!

0 Kudos

Thanks Marian, this was not my question, would you be able to drop a comment in mine and I can close it? Not sure if there is a better way. to link the questions.

Marian_Zeis
Active Contributor
0 Kudos

You´re right, did not check that