Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Tricky portal sorting wanted...


This topic is 6162 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a portal that users want to see items in the added record order (sorted by ID field), newest item on top. No problem... But then later re-Sort it by a color field to bunch like colored items to together.

I can't seem to figure out a way to dynamically allow users to toggle the portal's sort between the ID field and Color field

Anyone have a clever trick? Is there a way I'm not seeing?:)

Many thanks....

Dave

Posted

Is Color field a Container field or a text or number field? If it's a Container, you'll need to make it another kind, because you can't sort on Containers.

There's two schools of thought on this.

One is to create an unstored calculated field in the table that contains either the ID field or the Color field depending on what the user selects (usually adding a global field for the user selection). Set your portal to sort on this new calc field.

The other school of though is to make two portals each sorted differently and put them on different tabs, but lined up so you can't tell the difference. Take away all the borders from the tab and label each tab ID and Color respectively.

Posted

I was thinking along the same lines, just didn't have it quite right! I hate having to create another layout for the sake of the portal sorting! So here's what I came up with. Hopefully it's helpful to others....

Thanks

Dave

In the line items table:

Created a global field called "LineItemSortOrder"

Then created an unstored calculation field in my with: "ItemSortOrder"

If ( Ord::LineItemSortOrder="Entry Order" ; ID ; ItemColor )

Then added the following script to my Parent table to toggle between the two sorts.

Go to Related Record[show only related records; From Table:Orders: Using Layout: ]

IF [Orders::LineItemSortOrder="Entry Order"]

Set Field[Orders::ItemSortOrder; "ItemColor"]

Sort Records [Restore; No Dialog]

Else

Set Field[Orders::ItemSortOrder; "ID"]

Sort Records [Restore; No Dialog]

End IF

Refresh Window[]

I added the Sort Record[] to each IF statement to toggle between ascending and descending..

Posted

I'm glad I could help, but I don't understand what you're trying to do any more. Neither technique I described above requires a script.

Are you sorting a portal or a found set of records? Sorting a found set does nothing to the sort order of a portal which is determined by the sort order of the relationship superseded by the sort order defined in the portal itself.

Posted

I don't think your script is doing anything - you cannot sort records in a portal by a script.

Sorting a portal by a calculation field is problematic, especially when the fields are of different type. I don't think there are "two schools of thought on this" - the introduction of tab control in version 8 has made the other method obsolete.

This topic is 6162 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.