on 2023 Jul 04 10:17 AM
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
Seems like you need to extend the controller.
I used this example
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;
})
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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);
}
}
});
}
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.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.