2024 Aug 20 11:43 AM - edited 2024 Aug 20 11:45 AM
Hi Everyone
I have an oData EntitySet "CUSTOMER_HIER_LIST" directly binded to sap.ui.table.TreeTable using v2 oDataModel and displays the treetable rows using treeAnnotationProperties binding. Now I want to initialize a new field called "IS_SELECTED" for each row. I have a sap.m.CheckBox in each row to which I will bind it. This field is not present in the CUSTOMER_HIERARCHY_LIST entity's metadata. I am not able to use Table.addSelectionRows() as I have a custom requirement for row selection.
In the 'dataReceived' event of the tree binding, if I try to do like below, then I see the error in the browser console as "Assertion failed: IS_SELECTED is not a valid property path" which is true because the field is not present in the entity set.
onCustomerListDataRecieved: function(oEvent){
const oTreeTable = this.getView().byId("treeTableId"),
aBindingContexts = oTreeTable.getBinding("rows").getContexts();
aBindingContexts.forEach((oRowContext)=>{
//This works because the field is present in entityset
this.getModel("odataV2").setProperty("CUST_DESCR", "TEST CUSTOMER", oRowContext);
//This does not work as the field is not present in entityset's metdata
this.getModel("odataV2").setProperty("IS_SELECTED", false, oRowContext);
});
}
I can change the value of an existing field, but then is it even possible to add a new field to v2 oDataModel as above?
Any suggestions and solutions will be greatly appreciated.
Thanks,
Naresh
Request clarification before answering.
Unfortunately, in the case of OData binding, my suggestion is to add the attribute to the CUSTOMER_HIER_LIST. You can create a dummy attribute (if it's in a CDS, it might look like this):
cast ( '' as BOOLE_D ) as IS_SELECTEDThis should solve your issue.
Best regards,
Sebastiano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastiano.
Thanks for your reply. We are using CAPM NodeJs for oData services. But the CUSTOMER_HIER_LIST is actually an external service from another deployed CAPM app. So I was wondering if we can use the above cds code in srv folder's cds file. We have the following definition currently.
using { DealService as DS } from '../srv/external/DealService';
service camps @(requires: 'authenticated-user') {
entity CUSTOMER_HIER_LIST as projection on DS.CUSTOMER_HIER_LIST ;
// ... Other service definitions
}
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.