From 10db065201286d5637701041141558965053090e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 14 Jul 2023 20:01:04 +0200 Subject: [PATCH] DataSource: Find() method now takes the ascending / descending sort order into account. [GB.DB.FORM] * BUG: DataSource: Find() method now takes the ascending / descending sort order into account. * BUG: DataView: The MoveTo() method raises the Activate event when it was in creation mode before moving. * NEW: DataView: MovePrevious() moves to the last record if we are in creation mode. * NEW: DataView: MoveNext() has no effect if we are in creation mode. --- comp/src/gb.db.form/.src/DataTable.class | 9 +-------- comp/src/gb.db.form/.src/DataView.class | 10 ++++------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/comp/src/gb.db.form/.src/DataTable.class b/comp/src/gb.db.form/.src/DataTable.class index 35c95a9d6..f74698c98 100644 --- a/comp/src/gb.db.form/.src/DataTable.class +++ b/comp/src/gb.db.form/.src/DataTable.class @@ -167,17 +167,10 @@ End Public Sub Find(sWhere As String, Optional iFrom As Integer) As Integer Dim sReq As String - Dim aSort As String[] - Dim I As Integer Dim sSelect As String Dim rFind As Result - aSort = GetSortKeys().Copy() - For I = 0 To aSort.Max - aSort[I] = $DB.Quote(aSort[I]) - Next - - sSelect = "ROW_NUMBER() OVER (ORDER BY " & aSort.Join() & ") AS __index" + sSelect = "ROW_NUMBER() OVER (" & $DB.SQL.OrderBy(GetSortKeys())() & ") AS __index" sReq = $DB.SQL.Select([sSelect, "*"]).From($sTable).Where($sFilter)() sReq = "SELECT * FROM (" & sReq & ") WHERE " & sWhere diff --git a/comp/src/gb.db.form/.src/DataView.class b/comp/src/gb.db.form/.src/DataView.class index 92a8e1048..50690bb84 100644 --- a/comp/src/gb.db.form/.src/DataView.class +++ b/comp/src/gb.db.form/.src/DataView.class @@ -275,7 +275,6 @@ Public Sub Update() End - Private Function Columns_Read() As String[] Return $aColumns.Copy() @@ -804,10 +803,7 @@ End Public Sub MoveNext() - If $bCreate Then - MoveFirst - Return - Endif + If $bCreate Then Return If $hCtrl.Row >= $hCtrl.Rows.Max Then Return If $hCtrl.Row < 0 Then Return Inc $hCtrl.Row @@ -818,7 +814,7 @@ End Public Sub MovePrevious() If $bCreate Then - MoveFirst + MoveLast Return Endif If $hCtrl.Row <= 0 Then Return @@ -829,6 +825,8 @@ End Public Sub MoveTo(Index As Integer) + If Index = Index_Read() Then Return + If $bCreate Then $hCtrl.Row = -1 SetCreate(False) $hCtrl.Row = Index $hCtrl.Rows[$hCtrl.Row].Selected = True