OnBeforeSortColumn
#1
Posted 25 January 2005 - 11:55 PM
is there a way to do something right before OnSortColumn?
The Event OnSortColumn occurs after the sorting is finished, but I need the state from BeforeSortColumn.
Because my prog saves the the current ID (row) and if someone sorts a column the ID belongs to a other row with other contents.
I could do this by saving something in this row and find it afterwards, but if there's a possibility, I would prefer the other way.
greetz,
Steffen
#2
Posted 27 January 2005 - 08:27 AM
Mark Finkle
#3
Posted 27 January 2005 - 09:17 PM
I will see what I can do
probably I will add it
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#4
Posted 13 February 2015 - 12:47 PM
Sorry to bump this old post.
Since I don't see something like "OnBeforeSortColumn":
Is there a good work-around for my (and MFinkle's) problem that selected rows are deselected after sorting...
.sundance.
#5
Posted 15 February 2015 - 05:24 AM
Hi Sundance,
I think that this bug is fixed long ago Can you please confirm this in your version.
Thanks.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#6
Posted 15 February 2015 - 04:01 PM
Hi Boki,
I'm using lastest version of NextGrid v5.9.50 (Delphi 7).
To reproduce the behaviour, I dropped a TNextGrid and a TButton on a Form, added 3 Columns (2 x nxNumberColumn, 1 x nxTextColumn), set these options ([goHeader,goMultiSelect,goSelectFullRow]) and fill the grid with some lines:
procedure TForm1.btFillClick(Sender: TObject); const NumLines = 10; var i,k: Integer; begin NextGrid.AddRow(NumLines); for i:=0 to NextGrid.RowCount-1 do begin k := Random(100); NextGrid.Cell[0,i].AsInteger := i; // Index NextGrid.Cell[1,i].AsInteger := k; // Random number NextGrid.Cell[2,i].AsString := 'This is info text #' + IntToStr(i); end; end;
Now I do this:
a. Click on the column header of the random number
b. Select any 3 lines with click & ctrl-click
c. Click on the column header of the index number
Expectation: The three lines selected in a) are still selected while their rows have changed because of resorting
Reality: Only one line is selected (the one with the highest row number before c)
Hope this helps to verify the problem.
Thanks in advance.
.sundance.
#7
Posted 16 February 2015 - 05:32 AM
Hi,
Please try to completely replace next method in NxGrid.pas
var ASortKind: TSortKind; ASelectedRow: TRow; begin inherited; ASelectedRow := nil; if coCanSort in AColumn.Options then begin if Asending then ASortKind := skAscending else ASortKind := skDescending; { Remember selected row } if RowExist(SelectedRow) then ASelectedRow := FCells.Row[SelectedRow]; FCells.SortColumn(AColumn.Index, AColumn.SortType, ASortKind, coFullResort in AColumn.Options); { Find old selected row (after sorting) and set it active } if Assigned(ASelectedRow) then begin SelectCell(SelectedColumn, FCells.GetRowIndex(ASelectedRow), [], False); // SelectedRow := FCells.GetRowIndex(ASelectedRow); end; if SelectedRow > -1 then ScrollToRow(SelectedRow); { Retreive FFirstRow again. Find row with visible (!) index = VertScrollBar.Position } FFirstRow := GetFirstRow; FFirstVisibleRow := GetFirstVisible(0); FLastVisibleRow := GetLastVisible(Pred(RowCount)); RefreshArea(gaBody); if goIndicator in Options then RefreshArea(gaIndicator); DoAfterSort(AColumn.Index); end; end;
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#8
Posted 16 February 2015 - 05:32 AM
Please tell me how it works now.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#9
Posted 18 February 2015 - 12:20 PM
Please try to completely replace next method in NxGrid.pas
Please tell me how it works now.
I'd love to, but I don't have the NextGrid sources. Did my tests with the free D7 component.
Maybe you could provide a beta compilation for D7 with your recent changes.
.sundance.
#10
Posted 18 February 2015 - 01:35 PM
Hi,
I am not sure, maybe I have already included it in latest free release (Feb 16).
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#11
Posted 19 February 2015 - 10:47 PM
Yes, you did!
NextGrid v5.9.55 works like a charm and fixes the reported issue.
Boki, you're da man!
.sundance.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users