@@ -54,9 +54,9 @@ Implements WebDataSource
5454 If (Me . Table = Nil ) Then Return Nil
5555
5656 Var rowIndex As Integer = Me . Table. SelectedRowIndex
57- If (rowIndex < 0 ) Then Return Nil
57+ If (rowIndex < 0 ) Or (rowIndex > Me . TableRows . LastIndex) Then Return Nil
5858
59- Return Me . Table . RowTagAt (rowIndex)
59+ Return Me . TableRows (rowIndex).Lookup( "rowtag" , Nil )
6060
6161 End Function
6262 #tag EndMethod
@@ -198,7 +198,6 @@ Implements WebDataSource
198198
199199 Var row As New WebListBoxRowData
200200 row. PrimaryKey = Me . TableRows(i).Lookup("id" , -1 ).IntegerValue
201- row. Tag = dictRow
202201
203202 For Each col As DatasourceColumn In Me . Columns
204203 Var colData As Variant = Me . TableRowColumnData(col, dictRow)
@@ -227,6 +226,8 @@ Implements WebDataSource
227226 End Select
228227 Next
229228
229+ dictRow. Value("rowtag" ) = dictRowTag
230+
230231 row. Tag = dictRowTag
231232 rows. Add(row)
232233
@@ -439,6 +440,35 @@ Implements WebDataSource
439440 End Sub
440441 #tag EndMethod
441442
443+ #tag Method, Flags = &h1
444+ Protected Function TableRowFindAndSelect (findByFields As Dictionary) As Boolean
445+ If (Me . TableRows = Nil ) Or (Me . TableRows. LastIndex < 0 ) Then Return False
446+ If (findByFields = Nil ) Or (findByFields. KeyCount < 1 ) Then Return False
447+
448+ Var tableRow As Dictionary
449+ Var bAllFieldsFound As Boolean
450+ For i As Integer = Me . TableRows. LastIndex DownTo 0
451+ tableRow = Me . TableRows(i)
452+
453+ bAllFieldsFound = True
454+ For Each field As Variant In findByFields. Keys
455+ If (tableRow. Lookup(field. StringValue, "" ).StringValue <> findByFields. Value(field).StringValue) Then
456+ bAllFieldsFound = False
457+ Exit 'Loop matching Fields
458+ End If
459+ Next
460+
461+ If (Not bAllFieldsFound) Then Continue 'searching next Table Row
462+
463+ Me . Table. SelectedRowIndex = i
464+ Return True
465+ Next
466+
467+ Return False
468+
469+ End Function
470+ #tag EndMethod
471+
442472 #tag Method, Flags = &h21
443473 Private Function UnsortedPrimaryKeys () As Integer ()
444474 // Part of the WebDataSource interface.
0 commit comments