cancel
Showing results for 
Search instead for 
Did you mean: 

Can we perform Distinct and Grouping operation on OData services ??

former_member197578
Participant
0 Kudos

Hello Experts,

I am using an OData service whose output consists of few repeated rows. I want to display distinct data in the UI and also group the repeated rows. Can this manipulation be done in the service itself ??

Following is the scenario:

Lets say a customer orders same product in two different categories(different packs,but same product). Only one order number is generated for this order, but its displayed twice in the output because categories of product are different.  In my table, Order number must be visible only once and under "no of items" 2 must be displayed.(Hence grouping is required).

I hope i have explained my question properly.

Please reply,

Thnak you,

Best Regards,

Chetna

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

No, this is not possible in the service level, unless you try to do comparison and start blanking out properties in the DPC class.

I would not recommended this as well, as the requirement is more at 'How you display', and not about the data.

former_member197578
Participant
0 Kudos

Could you please suggest some way ? Table gets directly binded to the Model, so how to remove this additional row from the model so that only required entries get binded.

Thank you,

Regards,

Chetna

sreehari_vpillai
Active Contributor
0 Kudos

Chetna,

Each item in the entity set is identified with a unique (set of ) key. Then how come you get duplicate values By the way , if you are not displaying the key, there are chances to get duplicated records in the UI table. Handle from data model level.

Sree

former_member197578
Participant
0 Kudos

Its not like that i am getting duplicate values, actually the scenario is something like this: if i place an order in flipkart for two different products or same product having different categories or packs alltogether, then though products are different, only one order number will be generated.

Now the output i receive from the service is i think on the basis of products which has been ordered. So when two products which were ordered by a person are displayed , With them the order id will also be displayed. In such cases same order id will be repeated for those two products which were ordered together.

I just want:

(1) to bind Distinct entries to my table, and

(2) group the two entries so that i can display no of items = 2 , for this order number

Do you any idea as to how can i approach dis?

Thank you,

Best Regards

sreehari_vpillai
Active Contributor
0 Kudos

You can not o this from the odata service level . You will need to create another entity as expected and handle this situation from data provider class. Or , you will need to use odata.read() method to call the service after constructing your URL and manipulated thae returned JSON before binding it to the table .

Sree

Answers (0)