You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bolero do not (dispatch GetBooks sql) in QuickGrid's GridItemsProvider .
Excepct
Bolero do (dispatch GetBooks sql) in QuickGrid's GridItemsProvider .
// What I really want ...
SQL is executed and data is displayed each time you scroll with the mouse
Environment Information
ver
Microsoft Windows [Version 10.0.19045.2486]
dotnet --version
7.0.102
client
<PackageReference Include="Bolero" Version="0.*"/><PackageReference Include="Bolero.Build" Version="0.*"/><PackageReference Include="Bolero.HotReload" Version="0.20.4"/><PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid" Version="0.1.0-alpha.22351.1"/><PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.*"/>
server
<PackageReference Include="Bolero.Server" Version="0.*"/><PackageReference Include="Bolero.HotReload.Server" Version="0.20.4"/><PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.*"/>
C# model code
C# model code
code is here :
https://aspnet.github.io/quickgridsamples/datasources
> Remote Data
@injectHttpClient Http
@inject NavigationManager NavManager
<div class="grid" tabindex="-1"><QuickGrid ItemsProvider="@foodRecallProvider"Virtualize="true"><PropertyColumn Title="ID"Property="@(c => c.Event_Id)"/><PropertyColumn Property="@(c => c.State)"/><PropertyColumn Property="@(c => c.City)"/><PropertyColumn Title="Company" Property="@(c => c.Recalling_Firm)"/><PropertyColumn Property="@(c => c.Status)"/></QuickGrid></div><p>Total:<strong>@numResults results found</strong></p>
@code {
GridItemsProvider<FoodRecall>? foodRecallProvider;intnumResults;protectedoverrideasync Task OnInitializedAsync(){// Define the GridItemsProvider. Its job is to convert QuickGrid's GridItemsProviderRequest into a query against// an arbitrary data soure. In this example, we need to translate query parameters into the particular URL format// supported by the external JSON API. It's only possible to perform whatever sorting/filtering/etc is supported// by the external API.foodRecallProvider=async req =>{varurl= NavManager.GetUriWithQueryParameters("https://api.fda.gov/food/enforcement.json",newDictionary<string,object?>{{"skip", req.StartIndex },{"limit", req.Count },});varresponse=await Http.GetFromJsonAsync<FoodRecallQueryResult>(url, req.CancellationToken);return GridItemsProviderResult.From( items:response!.Results, totalItemCount:response!.Meta.Results.Total);};// Display the number of results just for information. This is completely separate from the grid.numResults=(await Http.GetFromJsonAsync<FoodRecallQueryResult>("https://api.fda.gov/food/enforcement.json"))!.Meta.Results.Total;}}
F# Code ( I try it )
View
letdataPage model (username:string)dispatch =letdic:ref<seq<IDictionary<string,string>>>= ref null
.quickGrid(
div {
comp<QuickGrid'<IDictionary<string,string>>>{"Virtualize"=>true"ItemsProvider"=> GridItemsProvider (myfunc dispatch model dic)// display columns..// omit...}})
myfunc ( I would do dispatch GetBooks in myfunc )
letmyfunc dispatch model (dic:ref<seq<IDictionary<string,string>>>)=fun(req:GridItemsProviderRequest<IDictionary<string,string>>)->task{// 1. Create SQLlettableRowStartNumber= req.StartIndex
lettableRowDisplayEnableCount= req.Count
letsql= $"select * from books where rowid between {tableRowStartCount} and {tableRowDisplayEnableCount}"// 2. Send sql
dispatch GetBooks sql
// 3. Recieved result
dic.Value <- model.books.Value
return GridItemsProviderResult.From(
items=(dic.Value.ToList()), totalItemCount= dic.Value.Count())}|> ValueTask<GridItemsProviderResult<IDictionary<string,string>>>
What happens here is that the message is dispatched; but the dispatch function just queues the message to be processed. It doesn't wait for it (or the Cmds it caused) to be completed. So when you look at the model right after calling it, nothing has changed yet.
I think a good way of doing this would be to pass a callback in GetBooks, that would be called at the end of processing it in the update function.
Problem Summary
I try DataGrid ( QuickGrid- vertualizing ) .
Bolero do not (dispatch GetBooks sql) in QuickGrid's GridItemsProvider .
Excepct
Bolero do (dispatch GetBooks sql) in QuickGrid's GridItemsProvider .
Environment Information
C# model code
C# model code
F# Code ( I try it )
View
myfunc ( I would do dispatch GetBooks in myfunc )
definition ( GridItemsProvider )
The text was updated successfully, but these errors were encountered: