private void UpdateUrl(int page) { bool isSearch = SearchColumns != null && SearchColumns.Count > 0; if (page == 1 && _NavigationManager.Uri.IndexOf("?") < 1 && !isSearch) { return; } string sortOrder = _UrlManager.GetQueryParm("sortOrder"); string sortBy = _UrlManager.GetQueryParm("sortby"); _UrlManager.Reset(); if (_UrlManager.Uri.isNOEOW()) { _UrlManager.Uri = PageName;// _UrlManager.GetNavigate(_NavigationManager.Uri); } //Console.WriteLine($"Cleaned URL => {_NavigationManager.Uri}"); //_UrlManager.RemoveParm("pageSize"); _UrlManager.AddQueryParm("page", page.ToString(), true); if ((!sortOrder.isNOEOW() && !sortBy.isNOEOW()) && new[] { "asc", "desc" }.Contains(sortOrder)) { _UrlManager.AddQueryParm("sortOrder", sortOrder); _UrlManager.AddQueryParm("sortby", sortBy); } if (isSearch && !isFirstRender && !_NavigationManager.Uri.isNOEOW()) { foreach (string k in SearchColumns) { if (k != "page" && k != "pageSize") { string v = SearchColumns[k]; if (k.isNOEOW() || v.isNOEOW()) { continue; } _UrlManager.AddQueryParm(k, v); v = null; } } } else if (SearchColumns != null) { SearchColumns.Clear(); } var uri = _UrlManager.GetNavigate(_NavigationManager.Uri); //var old = _UrlManager.GetNavigate(_NavigationManager.Uri); //Console.WriteLine($"Old => {_NavigationManager.Uri}"); //Console.WriteLine($"New => {uri}"); _NavigationManager.NavigateTo($"{uri}"); }
protected void LocationChanged(object sender, LocationChangedEventArgs e) { if (setStateChange && this.isNoQueryString()) { setStateChange = false; SearchColumns.Clear(); customSearch.user_name = null; StateHasChanged(); } else { setStateChange = true; } OnSearch = false; }
void LocationChanged(object sender, LocationChangedEventArgs e) { if (_NavigationManager.Uri.isNOEOW() || _NavigationManager.Uri.IndexOf("?") < 1 || PageName.IndexOf("&") < 1) { _UrlManager.Uri = e.Location; if (_UrlManager.GetQueryParm("page").isNOEOW()) { CurrentPage = 1; } SearchColumns.Clear(); } if (!PageName.isNOEOW() && _UrlManager.GetAbsolutePath(_NavigationManager.Uri) == _UrlManager.GetAbsolutePath(PageName)) { Task.Run(async() => await LoadData(e.Location)); } }