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