Grid Sorting On Multiple Columns

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
James-S
Profound User
Posts: 61
Joined: Tue Jun 28, 2016 12:53 pm
First Name: James
Last Name: Sherwood
Company Name: Brunswick Boat Group
City: Knoxville
State / Province: Tennessee
Contact:

Grid Sorting On Multiple Columns

Post by James-S »

Hi.

I have a requirement to sort on multiple columns simultaneously. To simplify it will begin as a left to right column sort. Later it will be enhanced to allow the user to select the column sort order and ascending/descending from a pop-up panel. In short, the user(s) are requesting column sorting functionality similar to Excel.

I may be overlooking this but I only see single column sorts in grid properties. Is there a javascript way to do this?
grid sort properties.jpg
grid sort properties.jpg (32.11 KiB) Viewed 3768 times
User avatar
Megan
Profound Logic Staff Member
Posts: 90
Joined: Mon Sep 11, 2017 12:15 pm
First Name: Megan
Last Name: Bond
Company Name: Profound Logic
Phone: 5623227473
State / Province: California
Zip / Postal Code: 92692
Country: United States
Contact:

Re: Grid Sorting On Multiple Columns

Post by Megan »

Hello James,

Currently, Profound UI only provides single column sort. We do provide a way for customers to define their own sort function though. This can be done with the Grid Sort Function API, described on our documentation page here: http://www.profoundlogic.com/docs/displ ... t+Function.

Please let us know if this will work for you.

Thanks,
~MEGAN BOND
Technical Support Specialist
support@profoundlogic.com
James-S
Profound User
Posts: 61
Joined: Tue Jun 28, 2016 12:53 pm
First Name: James
Last Name: Sherwood
Company Name: Brunswick Boat Group
City: Knoxville
State / Province: Tennessee
Contact:

Re: Grid Sorting On Multiple Columns

Post by James-S »

Hi Megan.

Thank you for your reply. I got the same api code from Emily in a support submission. However, in that particular instance it was to help with a grid formatting issue we were having which we have now found a solution.

As for this code snippet and the online documentation, it shows it as a configuration option which makes it seem universal instead of specific screens. Also, I am not fully understanding where value1 and value2 would be obtained from since this would be across different rows.

Maybe loading the data from RPGLE in the sort sequence desired is the best solution but I was hoping someone may know a way to do this dynamically on the client side to avoid the overhead of I/O when the user wants to quickly resort multiple columns.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Grid Sorting On Multiple Columns

Post by Scott Klement »

James,

It is a JavaScript function, which are always global, but can be updated or removed separately on each screen if you want each screen to behave differently.

Keep in mind that the sort of a grid is based on which column the user clicks. Sure, you can also set the default of this by setting the "iniital sort" property that you've cited, but that's just the default and the user can change it. Making it possible to sort multiple columns would require completely changing the way things work, instead of simply clicking the column, you'd need to bring up a dialog where they select which columns to sort. it'd be a big change that would make things less simple.

For this reason, we added the sort function, allowing programmers to override this behavior in whichever way makes sense to them. After all, our customers are programmers, so this gives them full flexibility.

value1 and value2 are filled in by JavaScript when it is asked to sort the grid, you don't have to populate them yourself. Yes, they are coming from multiple rows of the grid. I don't understand why that matters to you?

Doing the sort yourself in the RPG program would also work, of course.
James-S
Profound User
Posts: 61
Joined: Tue Jun 28, 2016 12:53 pm
First Name: James
Last Name: Sherwood
Company Name: Brunswick Boat Group
City: Knoxville
State / Province: Tennessee
Contact:

Re: Grid Sorting On Multiple Columns

Post by James-S »

Hi Scott.

You are correct where the values comes from doesn't matter. I was just making referencing to not understanding where they get populated which you have explained. The entire goal for this exercise was to allow the user to have a way to override the default of a single column for sorting.

Where would you recommend to add this code at the screen level? onload?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Grid Sorting On Multiple Columns

Post by Scott Klement »

James,

Under the covers, we are simply calling the JavaScript sort() function, as described here:
https://www.w3schools.com/js/js_array_sort.asp

Then we intercept the function call shown in the example to add the additional parameters. But, otherwise, it is the normal JavaScript sort, so you can use it to do your comparison and return value as you would expect. You can therefore, have complete control over sorting.

I'm not sure that setting it in onload would work for the "initial sort column", due to the timing. I believe the initial sort is done before onload gets called... but it would work for when the user clicks the column. To make it work for the "initial sort column" you'd probably have to set it on a prior screen, etc.

In either case, you can use the onsubmit (screen-level) event to remove the sort function so that it does not affect later screens.
James-S
Profound User
Posts: 61
Joined: Tue Jun 28, 2016 12:53 pm
First Name: James
Last Name: Sherwood
Company Name: Brunswick Boat Group
City: Knoxville
State / Province: Tennessee
Contact:

Re: Grid Sorting On Multiple Columns

Post by James-S »

Scott,

I take the pui.gridsort is for manipulating the logic of the sorting when a user clicks a grid column? Only then the logic within the defined function will be used for sorting the grid?

To further explain, the requirement is to independently sort individual columns and maintain the previous row sort. Like in Excel you can sort on Column A, Column B, Column D.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Grid Sorting On Multiple Columns

Post by Scott Klement »

There's nothing built-in that will do that, James. You have to write it yourself, using the grid sort function, as we've been discussing.

Please understand that the goal of the grid was not to mimic Excel. It was to provide functionality similar to the "subfile" feature of 5250, or the grid features of GUI programming environments. We do offer a lot of functionality above and beyond what you were able to do in the green-screen, but our goal is not to turn it into a full-fledged spreadsheet software like Excel.

As a programmer, you are able to add your own functionality, which can be done via RPG or the Grid Sort Function. So if you want to sort multiple columns, that's up to you.
James-S
Profound User
Posts: 61
Joined: Tue Jun 28, 2016 12:53 pm
First Name: James
Last Name: Sherwood
Company Name: Brunswick Boat Group
City: Knoxville
State / Province: Tennessee
Contact:

Re: Grid Sorting On Multiple Columns

Post by James-S »

I completely agree to the purpose of grids and its relationship to subfiles. I'm finding our users expect more functionality like they would see in other browsers applications which are pure client/server. I feel that is just the users embracing browser interfaces for our platform. We try to come up with ways to do thing and utilizing Profound UI where appropriate and ask for enhancements that bring some of those user requests.

I'm doing some tests to incorporate the pui.gridsort logic you have suggested. I do want to offer something though and get your feedback. Since there are grid properties to sort the grid either by field name or column position, what do you think about a possible enhancement request to place custom grid sort javascript logic as a property? The idea would be to have the same initial property logic as the ones mention above.

I'm sure there is a reason the pui.gridsort is suggested at the global configuration level but for individual screens grids it would be intuitive to have it at a properties level.

Just some thoughts. The entire Profound team is great at listening to their customers ideas and implementing when it makes sense.

Thanks again. Look forward to your 6.0 presentation.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Grid Sorting On Multiple Columns

Post by Scott Klement »

The idea of a grid sort function property makes sense to me.

If you want to place a feature request, you can do that by e-mailing support@profoundlogic.com
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest