From 12a064af5127c28f26fc50a44cac7ffe36e23d54 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 20 Jan 2025 12:40:08 +0100 Subject: [PATCH] Format and generate code file --- .../Models/Snippets.generated.cs | 17 +++---- ...pleteVirtualizeAndReadDataExampleCode.html | 47 +++++++++++++++++++ ...completeVirtualizeAndReadDataExample.razor | 17 +++---- 3 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 Documentation/Blazorise.Docs/Pages/Docs/Extensions/Autocomplete/Code/AutocompleteVirtualizeAndReadDataExampleCode.html diff --git a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs index eb142de83f..46f7af905d 100644 --- a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs +++ b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs @@ -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""> @@ -5730,11 +5730,13 @@ protected override async Task OnInitializedAsync() @code { [Inject] public CountryData CountryData { get; set; } + public IEnumerable Countries; IEnumerable ReadDataCountries; int totalCountries; - + public string SelectedSearchValue { get; set; } + protected override async Task OnInitializedAsync() { Countries = await CountryData.GetDataAsync(); @@ -5742,18 +5744,17 @@ protected override async Task OnInitializedAsync() 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"
+              TValue="string"
+              Data="@ReadDataCountries"
+              TotalItems="totalCountries"
+              TextField="@(( item ) => item.Name)"
+              ValueField="@((item) => item.Iso)"
+              @bind-SelectedValue="@SelectedSearchValue"
+              Placeholder="Search..."
+              Virtualize
+              ReadData="@OnHandleReadData">
+    <NotFoundContent> Sorry... @context was not found! :( </NotFoundContent>
+</Autocomplete>
+
+
+@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();
+    }
+
+    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);
+        }
+
+        return Task.CompletedTask;
+    }
+}
+
+ diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/Autocomplete/Examples/AutocompleteVirtualizeAndReadDataExample.razor b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/Autocomplete/Examples/AutocompleteVirtualizeAndReadDataExample.razor index 7778f960da..df63325d35 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/Autocomplete/Examples/AutocompleteVirtualizeAndReadDataExample.razor +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/Autocomplete/Examples/AutocompleteVirtualizeAndReadDataExample.razor @@ -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"> @@ -15,11 +15,13 @@ @code { [Inject] public CountryData CountryData { get; set; } + public IEnumerable Countries; IEnumerable ReadDataCountries; int totalCountries; - + public string SelectedSearchValue { get; set; } + protected override async Task OnInitializedAsync() { Countries = await CountryData.GetDataAsync(); @@ -27,16 +29,15 @@ 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; } - } \ No newline at end of file