private async Task <bool> SetCurrentSortingWithEventCallback(IReadOnlyList <SortingItem <TItem> > newSorting) { CurrentUserState = CurrentUserState with { Sorting = newSorting }; previousUserState = CurrentUserState; // suppress another RefreshDataAsync call in OnParametersSetAsync await InvokeCurrentUserStateChangedAsync(CurrentUserState); return(true); }
private async Task <bool> SetCurrentPageIndexWithEventCallback(int newPageIndex) { if (CurrentUserState.PageIndex != newPageIndex) { CurrentUserState = CurrentUserState with { PageIndex = newPageIndex }; previousUserState = CurrentUserState; // suppress another RefreshDataAsync call in OnParametersSetAsync await InvokeCurrentUserStateChangedAsync(CurrentUserState); return(true); } return(false); }
/// <inheritdoc /> protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); Contract.Requires <InvalidOperationException>(DataProvider != null, $"Property {nameof(DataProvider)} on {GetType()} must have a value."); Contract.Requires <InvalidOperationException>(CurrentUserState != null, $"Property {nameof(CurrentUserState)} on {GetType()} must have a value."); Contract.Requires <InvalidOperationException>(!MultiSelectionEnabled || (ContentNavigationModeEffective != GridContentNavigationMode.InfiniteScroll), $"Cannot use multi selection with infinite scroll on {GetType()}."); if (firstRenderCompleted && (previousUserState != CurrentUserState)) /* after first render previousUserState cannot be null */ { // await: This adds one more render before OnParameterSetAsync is finished. // We consider it safe because we already have some data. // But for a moment (before data is refreshed (= before OnParametersSetAsync is finished), the component is rendered with a new user state and with old data). previousUserState = CurrentUserState; await RefreshDataAsync(); } previousUserState = CurrentUserState; }
/// <summary> /// Triggers the <see cref="CurrentUserStateChanged"/> event. Allows interception of the event in derived components. /// </summary> protected virtual Task InvokeCurrentUserStateChangedAsync(GridUserState <TItem> newGridUserState) => CurrentUserStateChanged.InvokeAsync(newGridUserState);