From df261a36ac481fc77757b793e77ffef8c241c61b Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 6 Apr 2021 14:17:38 +0200 Subject: [PATCH] LookupControl: fix values disappearing from popup on second open --- Controls.LookupGrid/LookupControl3.vb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Controls.LookupGrid/LookupControl3.vb b/Controls.LookupGrid/LookupControl3.vb index e44244b0..3d7cf7df 100644 --- a/Controls.LookupGrid/LookupControl3.vb +++ b/Controls.LookupGrid/LookupControl3.vb @@ -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)