FREE TRIAL

|

☀
☾
class

GridView

Inherits from ListView

A ListView whose list items can be arranged in a 2D layout.

Remarks

Percent-based Layout properties on UIBlocks parented directly to a GridView are calculated relative to their "virtual" parent GridSlice, not the GridView itself.

Properties

CrossAxis

The non-scrolling axis along which GridSlice's will position items.

CrossAxisItemCount

The number of elements to position along the CrossAxis.

MaxLoadedSliceIndex

The highest slice index currently loaded into the grid view.

MinLoadedSliceIndex

The lowest slice index currently loaded into the grid view.

PrimaryAxis

The scrolling axis to position elements in the grid. Assigned implicitly from the Axis configured on the UIBlock.

Methods

ClearSliceProvider

Clears any GridSliceProviderCallback<T> callback previously assigned via

  • SetSliceProvider(GridSliceProviderCallback<GridSlice>)
  • SetSliceProvider(GridSliceProviderCallback<GridSlice2D>)
  • SetSliceProvider(GridSliceProviderCallback<GridSlice3D>)
GetDataSourceAsGrid

Wraps the GridView's underlying data source in a GridList<T> to be indexable by a GridIndex, where Row is the index into the PrimaryAxis and Column is the index into the CrossAxis.

SetSliceProvider (3 overloads)
  1. Assigns the given GridSliceProviderCallback<T> as the sole handler for any grid slice requests. As a GridView is scrolled, new list items will be pulled into view, and CrossAxisItemCount list items will be visually parented to the returned GridSlice2D.
  2. Assigns the given GridSliceProviderCallback<T> as the sole handler for any grid slice requests. As a GridView is scrolled, new list items will be pulled into view, and CrossAxisItemCount list items will be visually parented to the returned GridSlice3D.
  3. Assigns the given GridSliceProviderCallback<T> as the sole handler for any grid slice requests. As a GridView is scrolled, new list items will be pulled into view, and CrossAxisItemCount list items will be visually parented to the returned GridSlice.
TryGetGridItem

Retrieves the ItemView representing the object in the data source at the provided GridIndex if it's paged into the GridView.

UpdateGridSlice

Invokes the configured grid slice provider, set via SetSliceProvider(GridSliceProviderCallback<GridSlice>), for the grid
slice at the given index, sliceIndex. Provides a way for the caller to reconfigure the visuals/layout of the requested grid slice.

Inherited Properties

DataSourceItemCount

The size of the underlying data source. Will return 0 if the underlying data source is null.

MaxLoadedIndex

The highest index into the data source mapped to a list item that's currently loaded into view.

MinLoadedIndex

The lowest index into the data source mapped to a list item that's currently loaded into view.

OutOfViewDistance

The distance a list item must be out of view before it's removed and added back into the list item pool.
Can be used as a spatial buffer in the event the rendered size of a list item extends beyond its LayoutSize.

UIBlock

The parent UIBlock of all the list items. Attached to this.gameObject.

Inherited Methods

AddDataBinder Subscribe to an indexed Data.OnBind<TData> event on this ListView's set of list items
AddDataUnbinder Subscribe to an indexed Data.OnUnbind<TData> event on this ListView's set of list items
AddGestureHandler Subscribe to an indexed IGestureEvent event on this ListView's set of list items
AddPrefabProvider

Register a PrefabProviderCallback<T> for a particular data type in the data source, TData.

GetDataSource

Retrieve the underlying data source, previously assigned via SetDataSource<T>(IList<T>).

JumpToIndex

Jumps the ListView to the item at the given index.

JumpToIndexPage

Jumps the ListView to the virtualized page of the item at the given index

Rebind

Reprocesses the object at index sourceIndex in the data source, invoking any necessary PrefabProviderCallback<T> callbacks, added via
AddPrefabProvider<TData>(PrefabProviderCallback<Int32>), and triggering a Data.OnBind<TData> event to refresh the list item content.

Refresh

Synchronizes the items in view with the content of the underlying data source, previously assigned via SetDataSource<T>(IList<T>).
Calls Rebind(Int32) for in-view elements, handles changes to the number of items in the data source, and will call Relayout() to ensure the view is filled.

Relayout

The ListView will pull more content into view and page content out of view as it's scrolled, but it doesn't automatically check for external
events causing its child list items to change in size. This utility provides a way to manually re-fill the list view or page out extraneous list items.

RemoveDataBinder Unsubscribe from an indexed Data.OnBind<TData> event previously subscribed to via AddDataBinder<TData, TVisuals>(UIEventHandler<Data.OnBind<TData>, TVisuals, Int32>)
RemoveDataUnbinder Unsubscribe from an indexed Data.OnUnbind<TData> event previously subscribed to via AddDataUnbinder<TData, TVisuals>(UIEventHandler<Data.OnUnbind<TData>, TVisuals, Int32>)
RemoveGestureHandler Unsubscribe from a gesture event previously subscribed to via AddGestureHandler<TEvent, TVisuals>(UIEventHandler<TEvent, TVisuals, Int32>)
RemovePrefabProvider

Unregister a PrefabProviderCallback<T> that was previously registered via AddPrefabProvider<TData>(PrefabProviderCallback<Int32>)

Scroll

Scrolls the list content by the provided delta along the UIBlock's AutoLayout.Axis

SetDataSource Set the underlying data source. This instructs the list to start creating a 1-to-1 mapping of objects in the data source to ListView list items.
TryDetach (2 overloads)
  1. Transfers ownership of the ItemView representing the object at data source index sourceIndex from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.
  2. Transfers ownership of the detached listItem from the ListView to the caller, allowing the caller to manipulate the listItem arbitrarily without fighting the ListView binding/prefab pooling system.
TryGetItemView

Attempts to retrieve the ItemView in view representing the object in the data source at the provided index, sourceIndex.

TryGetSourceIndex

Attempts to retrieve the index into the data source, sourceIndex, represented by the provided in-view listItem.

TryReattach

If a list item was previously detached from the ListView (via TryDetach(ItemView, Transform)), this is a way to transfer ownership of listItem back to the ListView.

Inherited Events

OnScrolledPastEnd

Invoked when the list is scrolled beyond the last list element. Provides the distance between the edge of content and edge of the viewport.

OnScrolledPastStart

Invoked when the list is scrolled beyond the first list element. Provides the distance between the edge of content and edge of the viewport.

☀
☾
In This Article
Legal EmailContact Github
Copyright © 2022 Supernova Technologies, LLC