optimize Pager search to remove redundant AllowSearch parameter and avoid consuming memory when not in use

This commit is contained in:
sbwalker
2023-10-12 11:10:14 -04:00
parent 6140743769
commit b77e72880b
10 changed files with 12 additions and 17 deletions

View File

@ -6,7 +6,7 @@
@if (ItemList != null)
{
@if (AllowSearch == "True")
@if (!string.IsNullOrEmpty(SearchProperties))
{
<div class="input-group my-3">
<input id="search" class="form-control" placeholder=@string.Format(Localizer["SearchPlaceholder"], SearchProperties) @bind="@_search" />
@ -234,9 +234,6 @@
[Parameter]
public Action<int> OnPageChange { get; set; } // a method to be executed in the calling component when the page changes
[Parameter]
public string AllowSearch { get; set; } // allow user to search items
[Parameter]
public string SearchProperties { get; set; } // comma delimited list of property names to include in search
@ -249,8 +246,6 @@
protected override void OnParametersSet()
{
AllItems = Items;
if (string.IsNullOrEmpty(Format))
{
Format = "Table";
@ -297,9 +292,9 @@
}
}
if (string.IsNullOrEmpty(AllowSearch) || string.IsNullOrEmpty(SearchProperties))
if (!string.IsNullOrEmpty(SearchProperties))
{
AllowSearch = "False";
AllItems = Items; // only used in search
}
if (!string.IsNullOrEmpty(PageSize))