How do I access index?
<Virtualize ItemsProvider="@ProvideItems">
<ItemContent>
<div>
Item: @context
Index: @???
</div>
</ItemContent>
</Virtualize>
" />
Item: @context Index: @??? Item: @context Index: @???
How do I access index?
<Virtualize ItemsProvider="@ProvideItems">
<ItemContent>
<div>
Item: @context
Index: @???
</div>
</ItemContent>
</Virtualize>
Copyright © 2021 Jogjafile Inc.
There isn't an index, you have to set it yourself using the
@key="myKey"attribute on the<ItemContent />child content. Even then, it doesn't exactly solve your problem of knowing the item's index. However,<Virtualize />can use the@keyattribute for tracking purposes when it comes to UI updates like filtering, ordering, adding, deleting, or updating. I use this component for rendering a dynamic dashboard with filtering/sorting capabilities by targeting the key and it works great.Example:
Reference: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-5.0#use-key-to-control-the-preservation-of-elements-and-components