Page 1 of 1


Posted: Mon Aug 12, 2019 4:52 pm
by jan

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.

Re: Sorting PRIM_LCOL

Posted: Tue Aug 13, 2019 7:38 am
by Stewart Marshall
If it's only a visual requirement, can't you sort the list on the screen?

Re: Sorting PRIM_LCOL

Posted: Tue Aug 13, 2019 9:37 am
by jan
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.

Re: Sorting PRIM_LCOL

Posted: Tue Aug 13, 2019 9:59 am
by Stewart Marshall
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.

Re: Sorting PRIM_LCOL

Posted: Tue Aug 13, 2019 5:11 pm
by jan
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.

Re: Sorting PRIM_LCOL

Posted: Wed Aug 14, 2019 9:35 am
by MarkD
Would a sorted collection work?

By listening to the #CollectionName.Compare event you can (dynamically) sort the collection into any order you like - ... ompare.htm

Re: Sorting PRIM_LCOL

Posted: Thu Aug 15, 2019 9:19 am
by jan
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.


Posted: Thu Aug 15, 2019 5:16 pm
by René Houba
I have an old example available related to PRIM_LCOL. Please let me know if you are interested.