-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...Pages/Docs/Extensions/Autocomplete/Code/AutocompleteVirtualizeAndReadDataExampleCode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"><</span><span class="htmlElementName">Autocomplete</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue">Country</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue">string</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">Data</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="sharpVariable"><span class="atSign">@</span>ReadDataCountries</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">TotalItems</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue">totalCountries</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">TextField</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue"><span class="atSign">@</span>(( item ) => item.Name)</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">ValueField</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue"><span class="atSign">@</span>((item) => item.Iso)</span><span class="quot">"</span> | ||
<span class="htmlAttributeName"><span class="atSign">@</span>bind-SelectedValue</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="sharpVariable"><span class="atSign">@</span>SelectedSearchValue</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">Placeholder</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="htmlAttributeValue">Search...</span><span class="quot">"</span> | ||
<span class="htmlAttributeName">Virtualize</span> | ||
<span class="htmlAttributeName">ReadData</span><span class="htmlOperator">=</span><span class="quot">"</span><span class="sharpVariable"><span class="atSign">@</span>OnHandleReadData</span><span class="quot">"</span><span class="htmlTagDelimiter">></span> | ||
<span class="htmlTagDelimiter"><</span><span class="htmlElementName">NotFoundContent</span><span class="htmlTagDelimiter">></span> Sorry... <span class="atSign">@</span>context was not found! :( <span class="htmlTagDelimiter"></</span><span class="htmlElementName">NotFoundContent</span><span class="htmlTagDelimiter">></span> | ||
<span class="htmlTagDelimiter"></</span><span class="htmlElementName">Autocomplete</span><span class="htmlTagDelimiter">></span> | ||
</pre></div> | ||
<div class="csharp"><pre> | ||
<span class="atSign">@</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<Country> Countries; | ||
IEnumerable<Country> 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 => x.Name.StartsWith(autocompleteReadDataEventArgs.SearchValue, StringComparison.InvariantCultureIgnoreCase)) | ||
.Skip(autocompleteReadDataEventArgs.VirtualizeOffset).Take(autocompleteReadDataEventArgs.VirtualizeCount); | ||
} | ||
|
||
<span class="keyword">return</span> Task.CompletedTask; | ||
} | ||
} | ||
</pre></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters