LookupControl: fix values disappearing from popup on second open

This commit is contained in:
Jonathan Jenne 2021-04-06 14:17:38 +02:00
parent 37cc6c9305
commit df261a36ac

View File

@ -49,6 +49,7 @@ Public Class RepositoryItemLookupControl3
SetDropdownButtonEnabled(_MultiSelect)
End Sub
Private Const NAME_DATATABLE_INTERNAL = "__INTERNAL_DATATABLE__"
Private Const TAG_DROPDOWN = "openDropdown"
Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm"
@ -165,8 +166,12 @@ Public Class RepositoryItemLookupControl3
NullText = Values.FirstOrDefault()
End If
If DataSource Is Nothing Then
Dim oDataTable As New DataTable()
' If No external Datasource is supplied, create one containing the currently selected values
' If the current datasource is the internal one, update it
If DataSource Is Nothing OrElse (TypeOf DataSource Is DataTable AndAlso DirectCast(DataSource, DataTable).TableName = NAME_DATATABLE_INTERNAL) Then
Dim oDataTable As New DataTable() With {
.TableName = NAME_DATATABLE_INTERNAL
}
oDataTable.Columns.Add(New DataColumn("Data", GetType(String)))
For Each oValue In Values
@ -248,9 +253,9 @@ Public Class RepositoryItemLookupControl3
If DataSource IsNot Nothing AndAlso DataSource.Columns.Count > 0 Then
Dim oFirstColumn As String = DataSource.Columns.Item(0).ColumnName
Dim oWrapped = SelectedValues.Select(Function(v As String)
Return $"'{v}'"
End Function).ToArray()
Dim oWrapped = SelectedValues.
Select(Function(v As String) $"'{v}'").
ToArray()
Dim oValueString As String = String.Join(",", oWrapped)
Dim oCriterium As String = $"[{oFirstColumn}] IN ({oValueString})"
View.ActiveFilterCriteria = DevExpress.Data.Filtering.CriteriaOperator.Parse(oCriterium)