org-scn-design-studio-community / sdkpackage

SDK Package of SCN Design Studio Community
Apache License 2.0
32 stars 29 forks source link

Accordion - Resorting Members #118

Open HenryTaylor opened 8 years ago

HenryTaylor commented 8 years ago

We're running DS 1.6 SP01, using Universes as data source, and the 3.0 version of the SDK.

I'm using an Accordion to display some information, but I'm having an issue with the sorting of the values for both the sections and the items. I want to use a specific sort, based on the value of another dimension in the Datasource. The Datasource returns the values in the correct sort order, but the getMembers function appears to be resorting in straight ascending value order. Is there a way to resort the values by another dimension value, after the getMembers is done?

Here's the code I'm using:

`ACCORDION_REPORT_SELECT.cleanAllElements();

var DS = DS_SECTIONS;
var DS2 = DS_REPORTS; var dimensions = DS.getDimensions();

dimensions.forEach(function(dimension, index) {
if(dimension.text == "Dashboard Section Display Name") { var members = DS.getMembers(dimension,999); members.forEach(function(member, index) { var key = Convert.replaceAll(member.text, " ", "_"); var extKey = member.externalKey; var text = member.text;
var url = "";
ACCORDION_REPORT_SELECT.addSection(key, text, url);
APPLICATION.createInfoMessage(text); if(!DS2.isInitialized()) { DS2.loadDataSource();
DS2.clearAllFilters(); }

        APPLICATION.setVariableValueExt("psEnter Dashboard Code", glblDashboardCode);
        APPLICATION.setVariableValueExt("psSectionDisplayName", extKey);                            

        var dimensions2 = DS2.getDimensions(Axis.ROWS);
        dimensions2.forEach(function(dimension2, index2)
        {           
            if(dimension2.text == "Dashboard Report Code - Display Name")
            {
                var members2 = DS2.getMembers(dimension2, 999);
                members2.forEach(function(member2, index)
                {
                    var intKey = member2.internalKey;  
                    // hack for unassigned as its key is empty!  
                    if (intKey == "") {  
                        intKey = "UNASSIGNED";  
                    }
                    var parentKey = key;  
                    var memberKey = parentKey + "|" + dimension2.name + "-" + intKey;  
                    var memberText = member2.text;  
                    var memberUrl = "";  
                    ACCORDION_REPORT_SELECT.addElement(parentKey, memberKey, memberText, memberUrl);
                });                 
            }
        });

        DS2.clearAllFilters();

    });
}

});`

KarolKalisz commented 8 years ago

Hi Henry,

we cannot influence the getMembers() method. It is returning the members as master data from backend, so the sequence is dependent on backend (some can allow sort, some not).

Option 1. have you tried to use the data iterator created by Mike? http://scn.sap.com/community/businessobjects-design-studio/blog/2016/02/08/design-studio-16-sdk--data-iterator--read-your-data-row-by-row-finally

This one will return you the complete result set - and this will keep the sort order in result set.

Option 2. You can put the members in Collection Utility and then sort by some rule (e.g. alphabet or value) (see http://scn.sap.com/docs/DOC-58081) Now available in Technical Components.

Karol

HenryTaylor commented 8 years ago

Thanks for the suggestions, Karol. I don't think they're going to work, though, unfortunately.

The Data Iterator has a restriction that at least 1 measure is required. I don't have measures in my Data Sources for these Accordion values. Just dimensions. When I try to use the getRows function, and I use the Ctrl-Space to try and access a dimension key value, there are none listed. I can only assume that it's because I don't have the requisite measure.

As for the Collection, if there's a way to do what I want with that, I lack the imagination or the tool knowledge/experience to see it. I just can't see how to create a single collection using the values from two dimensions (an ordinal and a value).