Fix: TagBox reloads on in-place Data refill
Improved MgGridFilterPanelTagBox<TData, TValue> to detect in-place Data collection refills and trigger DevExpress editor Reload(), ensuring tags resolve when the collection is updated without changing its reference. Updated MGGRID_PARAMETERS.md to document this behavior and clarify why Reload() is needed for in-place fills.
This commit is contained in:
parent
b06d321bfb
commit
d164a99ed9
|
|
@ -59,6 +59,7 @@ public class MgGridFilterPanelTagBox<TData, TValue> : MgTagBox<TData, TValue>, I
|
||||||
// fill the SAME instance later (AcObservableCollection.Replace) — the reference never changes, only
|
// fill the SAME instance later (AcObservableCollection.Replace) — the reference never changes, only
|
||||||
// the count does (0 => N). Count() is O(1) for ICollection-backed lookups.
|
// the count does (0 => N). Count() is O(1) for ICollection-backed lookups.
|
||||||
var dataCount = Data?.Count() ?? -1;
|
var dataCount = Data?.Count() ?? -1;
|
||||||
|
var sameInstanceRefilled = ReferenceEquals(Data, _lastSyncedData) && dataCount != _lastSyncedDataCount;
|
||||||
var dataChanged = !ReferenceEquals(Data, _lastSyncedData) || dataCount != _lastSyncedDataCount;
|
var dataChanged = !ReferenceEquals(Data, _lastSyncedData) || dataCount != _lastSyncedDataCount;
|
||||||
var selectionDrifted = Values is null || !Values.SequenceEqual(criteriaValues);
|
var selectionDrifted = Values is null || !Values.SequenceEqual(criteriaValues);
|
||||||
|
|
||||||
|
|
@ -66,6 +67,12 @@ public class MgGridFilterPanelTagBox<TData, TValue> : MgTagBox<TData, TValue>, I
|
||||||
{
|
{
|
||||||
_lastSyncedData = Data;
|
_lastSyncedData = Data;
|
||||||
_lastSyncedDataCount = dataCount;
|
_lastSyncedDataCount = dataCount;
|
||||||
|
|
||||||
|
// DevExpress snapshots the editor's item list and detects Data changes BY REFERENCE — an in-place
|
||||||
|
// fill is invisible to it, so the re-asserted Values could never resolve into tags (re-rendering
|
||||||
|
// does not help). Reload() (DxListEditorBase) forces the editor to re-read its Data source.
|
||||||
|
if (sameInstanceRefilled) Reload();
|
||||||
|
|
||||||
SetValuesCore(criteriaValues);
|
SetValuesCore(criteriaValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue