cancel
Showing results for 
Search instead for 
Did you mean: 

Master View Grouping on a expanded value

Former Member
0 Kudos

Dear community,

I want to group my entries in my Master View.

<List

            id="list"

            mode="{device>/listMode}"

            select="handleListSelect"

            items="{path: '/projects?$expand=customer,wbs_type,project_employees,project_status,details,time_trackings',

                 sorter: {

                    path : 'customer/CUSTOMER_NAME',

                    group: true

                 }

            }" >

The Grouping works but the app does not recognize same CUSTOMER_NAMEs

Two of the attached entries have the same CUSTOMER_ID but I want to group after their CUSTOMER_NAME.

How can I fix it.

Best regards,

Marcel

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Marcel,

Actually I didn't get you properly. If you are looking for custom grouping you can go through below link:

http://scn.sap.com/community/developer-center/front-end/blog/2013/11/29/custom-sorter-and-grouper

Thanks & Regards,

Namita

Former Member
0 Kudos

Hello,

I don't think that this is a custom grouper.

I have the following structure in table project which is binded to the Master List.

WBS_ELEM

...

CUSTOMER_ID

...

With expand customer, I can use customer/CUSTOMER_NAME for the output in the list. That works.

But If I group at CUSTOMER_ID it works but then the groupheader is an ID. I want to group after CUSTOMER_NAME.

And this partially works. The grouping header is correct, but why does come the values twice although they are not unique?

Best regards,

Marcel

Former Member
0 Kudos

Ok. This is strange, if both the customer names are same then it should come only once, but if it is not I mean by letters also in capital or lower case(both should be Identically same). But In the img I can see no difference on both names. Please check the data once.

An example of same value but different case - https://plnkr.co/edit/qYxPF7xT4lcUNrpA7pff?p=preview

here I made one "Available" to "available" so it's showing 3 groups.

Thanks

Former Member
0 Kudos

But the expand function gets the associated CUSTOMER_NAME to the CUSTOMER_ID so they are unique.

Any other ideas?

Former Member
0 Kudos

Grouping is done on ui level. So I guess, if you are grouping on CUSTOMER_NAME, the CUSTOMER_NAMEs should be unique, not the id's they are associated with, if I am getting you correctly.

Former Member
0 Kudos

That might be the issue.

I'm trying to make an workaround with: groupHeaderFactory: '.getGroupHeader'

But here I still have a problem.

View:

items="{path: 'MasterModel>/projects?$expand=customer,wbs_type,project_employees,project_status,details,time_trackings',

                 sorter: {

                    path : 'MasterModel>CUSTOMER_ID',

                    group: '.getGroup'

                 },

                 groupHeaderFactory: '.getGroupHeader'

            }" >

Controller:

getGroup: function (oContext)

    {

        var l_customerName;

        var l_customerId;

        //get CUSTOMER_NAME

        var oModel = this.getView().getModel("MasterModel");

        oModel.read("/customers", null, null, true, fSuccess, fError);

        function fSuccess(oEvent)

        {

            customerId = oContext.getProperty("CUSTOMER_ID") - 1;

            var oCustomers = new sap.ui.model.json.JSONModel(oEvent.results);

            l_customerName = oCustomers.getProperty("/" + customerId + "/CUSTOMER_NAME");

            //console.log(l_customerName);

        };

        function fError(oEvent){

         console.log("An error occured while reading Customers!")

        };

        return {

                key: l_customerId,

                title: l_customerName || "No Customer"

            };

    },

    getGroupHeader: function (oGroup){

        //Set Header

        console.log(oGroup);

        return new sap.m.GroupHeaderListItem( {

            title: oGroup.title,

            upperCase: false

        });

    },

But if I use "getGroup" the App does not call the methode getGroupHeader, only if I set group: true. But then I can't differntiate between a Key and a title.

Regrads,

Marcel

Jayakrishnan
Active Participant
0 Kudos

Hi,

  In your case customer is the data source name right? so replace the "/" by ">". Try it

Thank you,

Regards,

JK

Former Member
0 Kudos

Hi,

with > there is an endless loading.

customer is the name of an table.

In tha main table "projects" there is only CUSTOMER_ID.

I use phpodataproducer to put my mysql database in a odata service.

Any other ideas?

Regards,

Marcel