Skip to content

Commit

Permalink
Format and generate code file
Browse files Browse the repository at this point in the history
  • Loading branch information
stsrki committed Jan 20, 2025
1 parent 5ad2b43 commit 12a064a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 16 deletions.
17 changes: 9 additions & 8 deletions Documentation/Blazorise.Docs/Models/Snippets.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5721,7 +5721,7 @@ protected override async Task OnInitializedAsync()
TotalItems=""totalCountries""
TextField=""@(( item ) => item.Name)""
ValueField=""@((item) => item.Iso)""
@bind-SelectedValue=""selectedSearchValue""
@bind-SelectedValue=""@SelectedSearchValue""
Placeholder=""Search...""
Virtualize
ReadData=""@OnHandleReadData"">
Expand All @@ -5730,30 +5730,31 @@ protected override async Task OnInitializedAsync()
@code {
[Inject]
public CountryData CountryData { get; set; }

public IEnumerable<Country> Countries;
IEnumerable<Country> ReadDataCountries;
int totalCountries;


public string SelectedSearchValue { get; set; }

protected override async Task OnInitializedAsync()
{
Countries = await CountryData.GetDataAsync();
totalCountries = Countries.Count();
await base.OnInitializedAsync();
}

public string selectedSearchValue { get; set; }

private Task OnHandleReadData(AutocompleteReadDataEventArgs autocompleteReadDataEventArgs)
private Task OnHandleReadData( AutocompleteReadDataEventArgs autocompleteReadDataEventArgs )
{
if ( !autocompleteReadDataEventArgs.CancellationToken.IsCancellationRequested )
{
ReadDataCountries = Countries.Where( x => x.Name.StartsWith( autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase ) )
.Skip( autocompleteReadDataEventArgs.VirtualizeOffset ).Take( autocompleteReadDataEventArgs.VirtualizeCount );
ReadDataCountries = Countries
.Where(x => x.Name.StartsWith(autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase))
.Skip(autocompleteReadDataEventArgs.VirtualizeOffset).Take(autocompleteReadDataEventArgs.VirtualizeCount);
}

return Task.CompletedTask;
}

}";

public const string AutocompleteVirtualizeExample = @"<Autocomplete TItem=""Country""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<div class="blazorise-codeblock">
<div class="html"><pre>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">Autocomplete</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Country</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">string</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Data</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>ReadDataCountries</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">TotalItems</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">totalCountries</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">TextField</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>(( item ) =&gt; item.Name)</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">ValueField</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>((item) =&gt; item.Iso)</span><span class="quot">&quot;</span>
<span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-SelectedValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>SelectedSearchValue</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Placeholder</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Search...</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Virtualize</span>
<span class="htmlAttributeName">ReadData</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>OnHandleReadData</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">NotFoundContent</span><span class="htmlTagDelimiter">&gt;</span> Sorry... <span class="atSign">&#64;</span>context was not found! :( <span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">NotFoundContent</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">Autocomplete</span><span class="htmlTagDelimiter">&gt;</span>
</pre></div>
<div class="csharp"><pre>
<span class="atSign">&#64;</span>code {
[Inject]
<span class="keyword">public</span> CountryData CountryData { <span class="keyword">get</span>; <span class="keyword">set</span>; }

<span class="keyword">public</span> IEnumerable&lt;Country&gt; Countries;
IEnumerable&lt;Country&gt; ReadDataCountries;
<span class="keyword">int</span> totalCountries;

<span class="keyword">public</span> <span class="keyword">string</span> SelectedSearchValue { <span class="keyword">get</span>; <span class="keyword">set</span>; }

<span class="keyword">protected</span> <span class="keyword">override</span> <span class="keyword">async</span> Task OnInitializedAsync()
{
Countries = <span class="keyword">await</span> CountryData.GetDataAsync();
totalCountries = Countries.Count();
<span class="keyword">await</span> <span class="keyword">base</span>.OnInitializedAsync();
}

<span class="keyword">private</span> Task OnHandleReadData( AutocompleteReadDataEventArgs autocompleteReadDataEventArgs )
{
<span class="keyword">if</span> ( !autocompleteReadDataEventArgs.CancellationToken.IsCancellationRequested )
{
ReadDataCountries = Countries
.Where(x =&gt; x.Name.StartsWith(autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase))
.Skip(autocompleteReadDataEventArgs.VirtualizeOffset).Take(autocompleteReadDataEventArgs.VirtualizeCount);
}

<span class="keyword">return</span> Task.CompletedTask;
}
}
</pre></div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TotalItems="totalCountries"
TextField="@(( item ) => item.Name)"
ValueField="@((item) => item.Iso)"
@bind-SelectedValue="selectedSearchValue"
@bind-SelectedValue="@SelectedSearchValue"
Placeholder="Search..."
Virtualize
ReadData="@OnHandleReadData">
Expand All @@ -15,28 +15,29 @@
@code {
[Inject]
public CountryData CountryData { get; set; }

public IEnumerable<Country> Countries;
IEnumerable<Country> ReadDataCountries;
int totalCountries;


public string SelectedSearchValue { get; set; }

protected override async Task OnInitializedAsync()
{
Countries = await CountryData.GetDataAsync();
totalCountries = Countries.Count();
await base.OnInitializedAsync();
}

public string selectedSearchValue { get; set; }

private Task OnHandleReadData(AutocompleteReadDataEventArgs autocompleteReadDataEventArgs)
private Task OnHandleReadData( AutocompleteReadDataEventArgs autocompleteReadDataEventArgs )
{
if ( !autocompleteReadDataEventArgs.CancellationToken.IsCancellationRequested )
{
ReadDataCountries = Countries.Where( x => x.Name.StartsWith( autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase ) )
.Skip( autocompleteReadDataEventArgs.VirtualizeOffset ).Take( autocompleteReadDataEventArgs.VirtualizeCount );
ReadDataCountries = Countries
.Where(x => x.Name.StartsWith(autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase))
.Skip(autocompleteReadDataEventArgs.VirtualizeOffset).Take(autocompleteReadDataEventArgs.VirtualizeCount);
}

return Task.CompletedTask;
}

}

0 comments on commit 12a064a

Please sign in to comment.