cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table Grouping in Fiori Elements

rogerio_ribeiro2
Explorer
0 Likes
1,178

Hi experts,

I'm developing an application using fiori elements, with a template list page and object page.

I would like to group the table in the object page by Storage Location. It would be a regular grouping, without aggregation. I've tried using CDS annotations and XML annotations, without success.

In the annotation target, I've tried with the entity itself and also its container.

<Annotations Target="SAP__self.Container/zz_pv_stock_zite_assets">
                <Annotation Term="UI.PresentationVariant">
                    <Record Type="UI.PresentationVariantType">
                        <PropertyValue Property="GroupBy">
                            <Collection>
                                <PropertyPath>StorageLocation</PropertyPath>
                            </Collection>
                        </PropertyValue>
                        <PropertyValue Property="Visualizations">
                            <Collection>
                                <AnnotationPath>@UI.LineItem</AnnotationPath>
                            </Collection>
                        </PropertyValue>
                    </Record>
                </Annotation>
            </Annotations>

            <Annotations Target="SAP__self.zz_pv_stock_zite_assetsType">
                <Annotation Term="UI.PresentationVariant">
                    <Record Type="UI.PresentationVariantType">
                        <PropertyValue Property="GroupBy">
                            <Collection>
                                <PropertyPath>StorageLocation</PropertyPath>
                            </Collection>
                        </PropertyValue>
                        <PropertyValue Property="Visualizations">
                            <Collection>
                                <AnnotationPath>@UI.LineItem</AnnotationPath>
                            </Collection>
                        </PropertyValue>
                    </Record>
                </Annotation>
            </Annotations>

It doesn't work, however the grouping works when I do directly in the app using the engine icon.

What could be missing?

Thank you in advance, Rogerio

Accepted Solutions (0)

Answers (1)

Answers (1)

Senqi_Hu
Participant

https://sapui5.hana.ondemand.com/resources/sap/suite/ui/generic/template/js/AnnotationHelper-dbg.js 

I see that AnnotationHelper.js doesn't handle the annotation @ui.presentationVariant.groupBy, but does handle the annotation @ui.presentationVariant.sortOrder. This causes the annotation @ui.presentationVariant.sortOrder can work normally, and the annotation @ui.presentationVariant.groupBy  doesn't work. That's what I suspected.

But you can try it with front-end extension,  Put the following code into the ObjectPageExt.controller.js.

onBeforeRebindTableExtension: function(oRebindObject) {
    oRebindObject.getParameter("bindingParams").sorter.push(new sap.ui.model.Sorter("StorageLocation", true, true));
}

 group.jpg

 

rogerio_ribeiro2
Explorer
0 Likes
Hi, thank you for your suggestion. Please, let me know if ObjectPageExt.controller.js you mentioned, could be the custom section controller? I've included the same method in this corresponding custom section controller, but it's not sensible to the process when I load the application. Regards, Rogerio
mathieu_l1
Participant
0 Likes

Thank you, this worked for me. Is it possible to display the associated text on the group headers, instead of the id (but still group by the id) ?

And how to require the grouped field values to always be loaded even if it is not part of the displayed columns ? Otherwise the values of the groups are blank.