cancel
Showing results for 
Search instead for 
Did you mean: 

GroupBy CDS annotation is not working

PhilippeLefebvr
Discoverer
0 Kudos

I am using ABAP CDS and an Odata service to create a Fiori Elements app (List Report and Object Pages). I'm having issues with making the grouping annotation work correctly, while setting the grouping manually on the app works fine.

Here is the relevant code from the CDS:

 

 

[...]

@UI: {
  presentationVariant: [{
      groupBy: [ 'CriteriaType' ],
      sortOrder: {
        by: 'CriteriaType'
      },
      visualizations: [{
        type: #AS_LINEITEM
      }]
  }]
}
define view ZABAC_VOBJ_CRIT_NB_DEFAULT
  as select from ZABAC_VOBJECT_CRIT_NB
  association [*] to ZABAC_VCRILOADTYPE_TEXT    as _criteria_type_text on  $projection.CriteriaType = _criteria_type_text.CriteriaTypeId
  [...]
{
      [...]

      @ObjectModel.text.association: '_criteria_type_text'
      @ObjectModel.readOnly: true
      @EndUserText.label: 'Type de critère'
      // @UI.lineItem: [{ position: 25, importance: #HIGH }]
      _criteria.criteria_type       as CriteriaType,

      [...]
}

 

 

Here is how the table renders by default on the app (responsive table on an Object Page). Sorting does work correctly:

Philippe_Lefebv_0-1713878298060.png

I can set the grouping manually inside the app, so grouping is possible with this table type:

Philippe_Lefebv_1-1713878403888.png

The service has been refreshed and regenerated multiple times, and the metadata has been reloaded both on the backend side and on the Fiori Elements application. I also tried clearing/invalidating the caches, with no effect.

According to the documentation, the current version of the CDS should be enough to make this work. Am I missing something?

Thank you for your help

View Entire Topic
MioYasutake
Active Contributor
0 Kudos

@PhilippeLefebvr 

If you're using OData V4, try adding a UI.SelectionPresentationVariant that points to the UI.PresentationVariant.

https://sapui5.hana.ondemand.com/#/topic/49a6ba5b8d6946208322a9f7e16837c2

MioYasutake_0-1713955143719.png

 

PhilippeLefebvr
Discoverer
0 Kudos
I am unfortunately using OData V2, so this didn't solve the issue, even after trying