Sort on Hdr Click

Started by Tom Anderson, July 03, 2025, 11:12:15 AM

Previous topic - Next topic

Tom Anderson

I know you can set a sort for a grid column by clicking on a column header if enabled in the grid creation in Nomads.

Question: can you get the grid to sort on a particular column using code from within a program? In other words, cause the grid sort without user intervention.

Thanks!

Tom Anderson

James Zukowski

Have you tried using grd'sort=col_num or grd'sort$="Col Name" ...?
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Tom Anderson

James,

I tried the following but it doesn't work:

04550 LET GRID'SORT=5
04560 !
04570 GRID LOAD INPF_GRID.CTL,0,0,RR$

Suggestions?

Tom

James Zukowski

Try the LOAD first, then the SORT.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Loren Doornek

If your grid is named INPF_GRID, then you should use INPF_GRID.CTL'sort=5 (or -5 if you want to sort in reverse order).  You need to set the 'sort value AFTER data is loaded, and set it again if you reload the grid so that the newly-loaded data is sorted as expected. 

Whenever I need to reload a sorted item (grid or listbox), I will store the current sort that the user has selected using logic like "LET cur_sort=INPF_GRID.CTL'SORT". Then, after reloading the data in the grid/listbox, I'll set the sort back to whatever the user had previously selected using "LET INPF_GRID.CTL'SORT=cur_sort"

Tom Anderson

Got it to work!

Thanks for the assist.

Tom