PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Sort By Header Question  (Read 659 times)

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 67
    • View Profile
Sort By Header Question
« on: August 23, 2018, 01:21:17 PM »
 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

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3359
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Sort By Header Question
« Reply #1 on: August 23, 2018, 02:10:12 PM »
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.

Code: [Select]
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)*
0110 IF CTL=4 OR EOM=ESC THEN BREAK
0120 IF CTL<>x THEN CONTINUE
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

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 67
    • View Profile
Re: Sort By Header Question
« Reply #2 on: August 23, 2018, 05:25:13 PM »
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

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3359
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Sort By Header Question
« Reply #3 on: August 23, 2018, 09:48:04 PM »
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.