Author Topic: Maintaining a ReportView Column Sort  (Read 407 times)

chrislegarth

  • Newbie
  • *
  • Posts: 33
Maintaining a ReportView Column Sort
« on: March 28, 2018, 02:27:02 pm »
I have a form that has a ReportView displaying 13 columns of data.  I have code that will sort the columns ASC or DESC when the column header is pressed.
What I'd like to know and can't seem to figure out is is there a way to maintain the last column sort and direction after the ReportView is updated with new data.
The ReportView defaults back to sorting the first column ASC.  If necessary, I can post a sample ReportView as an example.

Any help would be appreciated.
Thanks!

td

  • Tech Support
  • *****
  • Posts: 2661
    • WinBatch
Re: Maintaining a ReportView Column Sort
« Reply #1 on: March 28, 2018, 03:18:46 pm »
If you are using an array to load your data you could use DialogControlState to remove the sort style, presort your input array using ArraySort on the last column, reload the control and then re-enable the sort style.


Code: Winbatch
; a2 is a new presorted array.
nSortStyle = @csAsort
DialogControlState(MyDialog_Handle, "ReportView_1", @dcsRemStyle, nSortStyle)            
DialogControlSet(MyDialog_Handle,"ReportView_1",@dcContents, a2)
DialogControlState(MyDialog_Handle, "ReportView_1", @dcsAddStyle, nSortStyle)
 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


chrislegarth

  • Newbie
  • *
  • Posts: 33
Re: Maintaining a ReportView Column Sort
« Reply #2 on: March 29, 2018, 06:34:46 pm »
Thanks!  I didn't think about sorting the array directly.  It worked perfectly!