Sorting PRIM_LCOL (RESOLVED)

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jan
Posts: 14
Joined: Thu Sep 06, 2018 12:36 pm

Sorting PRIM_LCOL (RESOLVED)

Post by jan » Mon Aug 12, 2019 4:52 pm

Hi,

I am working with a List Collection inside a Reusable Part that acts as a data model shared between components. There is a particular list that can be controlled by a Sort control in one of the Views I am displaying.

Using the Sort_List over the property of the List Collection ends up with compile errors. Is there a better alternative than:
  • Transferring the list collection's contents to a work list
  • Sorting the working list
  • Clearing the list collection
  • Putting back the sorted values from the working list to the list collection
I just want to know if there are any other efficient ways to go about this. The approach above is what I currently have implemented.

Thanks in advance.

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Sorting PRIM_LCOL

Post by Stewart Marshall » Tue Aug 13, 2019 7:38 am

If it's only a visual requirement, can't you sort the list on the screen?
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

jan
Posts: 14
Joined: Thu Sep 06, 2018 12:36 pm

Re: Sorting PRIM_LCOL

Post by jan » Tue Aug 13, 2019 9:37 am

Hi Stewart. Thanks for the response.

The way I display the list is by having all the data lie in a collection in a data model RP. Then the displayed list is controlled by pagination controls (page numbers, sorting, etc.) and gets only the data it needs to display from the data model depending on how the users use the pagination controls.

I did get by using the method I indicated in my original post but was just wondering if there were no other alternatives to that.

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Sorting PRIM_LCOL

Post by Stewart Marshall » Tue Aug 13, 2019 9:59 am

In that case, read through the lcol and put them in a kcol when you need to sort them.

You'll need to tinker with the key value if there are duplicates.
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

jan
Posts: 14
Joined: Thu Sep 06, 2018 12:36 pm

Re: Sorting PRIM_LCOL

Post by jan » Tue Aug 13, 2019 5:11 pm

Thanks again for the response Stewart.

I've never tried sorting Keyed Collections before. Do you mean to create a keyed collection keyed by the field I want to sort on? For example PRIM_KCOL<#Price #RP> Or PRIM_KCOL<#Product #RP>?

Unfortunately, I am a bit tight with my schedule right now so I will try this out when things settle down a bit. Thanks a lot.

MarkD
Posts: 625
Joined: Wed Dec 02, 2015 9:56 am

Re: Sorting PRIM_LCOL

Post by MarkD » Wed Aug 14, 2019 9:35 am

Would a sorted collection work? https://docs.lansa.com/14/en/lansa016/prim_saco.htm

By listening to the #CollectionName.Compare event you can (dynamically) sort the collection into any order you like - https://docs.lansa.com/14/en/lansa016/p ... ompare.htm

jan
Posts: 14
Joined: Thu Sep 06, 2018 12:36 pm

Re: Sorting PRIM_LCOL

Post by jan » Thu Aug 15, 2019 9:19 am

Hi Mark.

That is something I have never used nor was aware of. Seems to be an interesting concept.

I am just unsure if that would work while utilizing *ListFields. Ideally, I would have just sorted the LCOL but Sort_List only seems to work for Working Lists. Maybe I will give this a try sometime. Thanks.

René Houba
Posts: 60
Joined: Thu Nov 26, 2015 7:03 am

Sorting PRIM_LCOL

Post by René Houba » Thu Aug 15, 2019 5:16 pm

I have an old example available related to PRIM_LCOL. Please let me know if you are interested.

Post Reply