using System; using System.Collections.Generic; using System.Linq; using AntDesign.TableModels; namespace AntDesign { public partial class Table : ITable { private IDictionary> _dataSourceCache; private void FlushCache() { if (_dataSourceCache == null) { _dataSourceCache = new Dictionary>(); } else { _dataSourceCache.Clear(); } } int[] ITable.GetSelectedCacheKeys() { return _dataSourceCache.Where(x => x.Value.Selected).Select(x => x.Key).ToArray(); } private void FinishLoadPage() { if (_selection == null) return; // Clear cached items that are not on current page var currentPageCacheKeys = _selection.RowSelections.Select(x => x.RowData.CacheKey).ToHashSet(); var deletedCaches = _dataSourceCache.Where(x => x.Value.PageIndex == PageIndex && !currentPageCacheKeys.Contains(x.Key)).ToList(); var needInvokeChange = deletedCaches.Any(x => x.Value.Selected); deletedCaches.ForEach(x => _dataSourceCache.Remove(x)); _selection?.ChangeOnPaging(); if (needInvokeChange) { _selection.InvokeSelectedRowsChange(); } } } }