Hi Everyone,
I am creating a CAP application with Filter Bar and Smart table control using Flexible programming model and cds annotations.
Goal: Based on the selection of one drop down value I want to restrict few values of another drop down from Filter Bar. (I want if-else sort of conditional flexibility on the value selection from 1st drop down -- so that other drop down values can be manipulated) -- Using Annotations
Flexible Programming Model: I have tried out FPM with CAP cds annotations. I specifically wanted this below feature to work out for me:
4) Context-Dependent Value Help - https://sapui5.hana.ondemand.com/test-resources/sap/fe/core/fpmExplorer/index.html#/advancedFeatures...
but when I put context and conditions like SAP has maintained here in above guide. I am not able to make it work.
Is there any suggested way to approach this??
Or if anyone knows how to properly use context and conditions with CAP cds annotations?
It would be a great help!!
Thanks in advance!!
Abhijeet
Request clarification before answering.
Hi @abranjan ,
I could'nt find the solution through annotations, but via different route.
You will have to cache the selected value from the drop down locally in the runtime and use it as filter in the following manner.
srv.on('READ','Myentity',async req=>{
if(req.query.SELECT !== undefined){
const condtionLiteral =`DropDownFieldName='SelectedDropDownFieldValue'`
//instantiate the cxn parser object
const parser= cds.parse;
// parse cxn : resultant => {xpr:[ {ref:['DropDownFieldName']}, '=', {val:'SelectedDropDownFieldValue'} ]}
const cxnObject = parser.expr(condtionLiteral);
const cxnArray = [...cxnObject.xpr];
req.query.SELECT.where = cxnArray;
}
const data = await srv.run(req.query);
return data
})Please also have a look at this documentation of CXN - CXN-Expression Notation .Let me know if this works for you.
Thank you
Regards
Subramaniyam N
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.