/// <summary> /// Filter items /// </summary> private void FilterItems() { // Clear displayed items DisplayedItems.Clear(); // Do we have any items to filter? if (Items.Count > 0) { // Iterate over all items foreach (MItem item in Items) { // Do primary text contains searched word (filter) ? if (item.PrimaryText.ToLower().Contains(_filter.ToLower())) { // Add item to displayed-items collection DisplayedItems.Add(item); } } } // Redraw control Invalidate(true); // Force update component Component.Outdated = true; // Force update scroll-bar Scrollbar.ForceUpdate(); // Call resize OnResize(EventArgs.Empty); // Refresh control Refresh(); }
public void UpdateDisplayedItems() { DisplayedItems.Clear(); if (_selectedItem != null) { LoadSelectedItemToDisplayedItems(); } else { LoadSelectedSupplierItemsToDisplayedItems(); } }
private void ChangePage(int newPage) { if (newPage >= 1 && newPage <= PageCount) { CurrentPage = newPage; DisplayedItems.Clear(); foreach (T item in _items.Take(CurrentPage * PageSize).Skip((CurrentPage - 1) * PageSize)) { DisplayedItems.Add(item); } StateHasChanged(); } }
private void RefreshItems() { IEnumerable <T> items = Items.ToList(); if (SortFunction is not null && !string.IsNullOrWhiteSpace(_sortColumn)) { items = SortFunction(items, _sortColumn, _sortAscending); } if (FilterFunction is not null && !string.IsNullOrWhiteSpace(_filter)) { items = FilterFunction(items, _filter); } _items = items; if (Paginate) { PageCount = (int)Math.Ceiling(1.0 * _items.Count() / PageSize); if (PageCount <= 0) { DisplayedItems.Clear(); } else { ChangePage(Math.Clamp(CurrentPage, 1, PageCount)); } } else { DisplayedItems.Clear(); foreach (T game in _items) { DisplayedItems.Add(game); } } StateHasChanged(); }
/// <summary> /// Clears both Items and DisplayedItems collections. Resets selected item property. /// </summary> public void Clear() { // Reset selected item SelectedItem = null; // Clear items Items.Clear(); // Clear displayed items DisplayedItems.Clear(); // Redraw control Invalidate(true); // Force update component Component.Outdated = true; // Force update scroll-bar Scrollbar.ForceUpdate(); // Refresh control Refresh(); }