Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements SearchTermParamName without ApiUrl (#300) #301

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/MatBlazor/Components/MatTable/MatTable.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@inherits BaseMatTable
@typeparam TableItem
@inject System.Net.Http.HttpClient Http
@inject NavigationManager NavMan

@using System
@using System.Collections.Generic
Expand Down Expand Up @@ -159,6 +160,15 @@
StartPage = 1;
CurrentPage = StartPage;

// If search term name has been specified, fetch the value (if available) and perform search and filtering right away
if (!string.IsNullOrWhiteSpace(SearchTermParamName))
{
var uri = new Uri(NavMan.Uri);
SearchTerm = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query).TryGetValue(SearchTermParamName, out var type) ? type.First() : "";

if (!string.IsNullOrWhiteSpace(SearchTerm)) FilterData();
}

if (!string.IsNullOrWhiteSpace(ApiUrl) && (RequestApiOnlyOnce || LoadInitialData))
{
try
Expand Down
1 change: 1 addition & 0 deletions src/MatBlazor/MatBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.10" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down