@using MP.SPEC.Data @code { [Parameter] public List? AllRecords { get; set; } = null; [Parameter] public EventCallback EC_Close { get; set; } [Parameter] public EventCallback EC_ReqAdd { get; set; } private int numRecord = 5; protected string SearchVal { get => searchVal; set { if (searchVal != value) { searchVal = value; UpdateTable(); } } } private string searchVal = ""; private int totalCount = 0; private int currPage = 1; private bool isLoading = false; private List? ListRecords; private string btnSearchCss { get => string.IsNullOrWhiteSpace(SearchVal) ? "btn-secondary" : "btn-primary"; } private void ResetSearch() { SearchVal = ""; } protected override void OnParametersSet() { numRecord = 10; UpdateTable(); } private void UpdateTable() { ListRecords?.Clear(); totalCount = 0; if (AllRecords != null) { List tmpList = new List(AllRecords); // verifico ricerca if (!string.IsNullOrEmpty(SearchVal)) { tmpList = AllRecords.Where(x => x.Cognome.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || x.Nome.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)).ToList(); } ListRecords = tmpList .Skip(numRecord * (currPage - 1)) .Take(numRecord) .ToList(); totalCount = tmpList.Count; } } protected void SetNumPage(int newNum) { currPage = newNum; UpdateTable(); } protected void SetNumRec(int newNum) { currPage = 1; numRecord = newNum; UpdateTable(); } private async Task DoClose() { await EC_Close.InvokeAsync(true); } private async Task DoAdd(AnagOperatoriModel currRec) { // sollevo evento richiesta aggiunta ... await EC_ReqAdd.InvokeAsync(currRec); } }