Sort By Header Question

Started by Peter.Higgins, August 23, 2018, 01:21:17 PM

Previous topic - Next topic


 Assuming the user doesn't know for sure the grid has sort enabled then in a large Grid, it is difficult to tell if the application is hanging or sorting after clicking on the header.  Is there any way to intercept the event and post to the status line or hide the grid and show a progress bar during a sort? 

Mike King

Generally a Grid will sort in under a few seconds assuming a reasonable number of rows.  On my local PC a grid with 1000 rows sort virtually instantaneously whereas 5000 takes about 3 seconds.  Sort time will vary based on the randomness of the data.

You can also handle the sort request yourself and display something for the duration or as shown in the example below change the column header to RED for the duration.

0010 PRINT 'CS',
0020 GRID 10,@(5,1,40,10),SEP=","
0030 LET x=10
0040 LET x'sortonhdrclick=0
0050 FOR i=1 TO 10000
0060 GRID LOAD 10,0,i,STR(RND(1000)*i:"00000000")+",Item "+STR(i)+","
0070 NEXT i
0080 PRINT "Ready to sort"
0090 WHILE 1
0100 OBTAIN (0)*
0130 GRID READ x,col,row,eom$
0140 IF row<>-1 THEN CONTINUE
0150 LET x'colno.row.backcolour.$=STR(col)+SEP+STR(row)+SEP+"Lite Red"+SEP
0160 WAIT .1 ! orce refresh
0170 IF x'sort=col THEN LET x'sort=0-col ELSE LET x'sort=col
0180 LET x'colno.row.backcolour.$=STR(col)+SEP+STR(row)+SEP+"Default"+SEP
0190 WEND
Mike King
President - BBSysco Consulting


Thanks Mike,

In order to sort by header when using nomads using your method, I assume signal All will have to be set for the grid Focus event?   I've noticed with that configuration from the last question the captured grid focus CTL was always the control.ctl plus 15000 regardless of the navigation key or mouse button.  Is this normal as well? 

Mike King

Not certain why you need either signal all or on focus.
Setting SortOnHdrClick to zero generates a normal grid change event when a column header is clicked as these are treated like buttons.
Mike King
President - BBSysco Consulting