WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: chrislegarth on March 28, 2018, 02:27:02 PM

Title: Maintaining a ReportView Column Sort
Post by: chrislegarth 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!
Title: Re: Maintaining a ReportView Column Sort
Post by: td 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) Select
; 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)
Title: Re: Maintaining a ReportView Column Sort
Post by: chrislegarth on March 29, 2018, 06:34:46 PM
Thanks!  I didn't think about sorting the array directly.  It worked perfectly!