This is useful when external data changes. Virtualize.RefreshDataAsync instructs the component to rerequest data from its ItemsProvider. In the following example, a collection of DataRow is a non-generic collection, so an items provider delegate is used for virtualization: ValueTask> GetRows(ItemsProviderRequest request)ĭ().Skip(request.StartIndex).Take(request.Count), Return new ItemsProviderResult(employees, totalEmployees) NumEmployees, request.CancellationToken) Var employees = await EmployeesService.GetEmployeesAsync(request.StartIndex, Var numEmployees = Math.Min(request.Count, totalEmployees - request.StartIndex) The following example loads employees from an EmployeeService (not shown): private async ValueTask> LoadEmployees( If both are assigned, an InvalidOperationException is thrown when the component's parameters are set at runtime. The items provider can choose to retrieve the items with each request or cache them so that they're readily available.Ī Virtualize component can only accept one item source from its parameters, so don't attempt to simultaneously use an items provider and assign a collection to Items. The items provider then retrieves the requested items from a database or other service and returns them as an ItemsProviderResult along with a count of the total items. Job title of items provider receives an ItemsProviderRequest, which specifies the required number of items starting at a specific start index. In the following example, the LoadEmployees method provides the items to the Virtualize component: has the If you don't want to load all of the items into memory or the collection isn't a generic ICollection, you can specify an items provider delegate method to the component's Virtualize.ItemsProvider parameter that asynchronously retrieves the requested items on demand. A mix of HTML/Razor and Razor components.Plain HTML and Razor code, as the preceding example shows.The item content for the Virtualize component can include: If a non-generic collection supplies the items (for example, a collection of DataRow), follow the guidance in the Item provider delegate section to supply the items.
0 Comments
Leave a Reply. |