A list view is a list based view of a collections entities and provides additional functionality beyond a normal tree view such as pagination for large collections, custom data views, searching and bulk actions.
The list view configuration is a sub configuration of a FluidityCollectionConfig
instance and is accessing via it’s ListView
method.
Accesses the list view config of the given collection.
// Example
collectionConfig.ListView(listViewConfig => {
...
});
Sets the number of items to display per page for the given list view.
// Example
listViewConfig.SetPageSize(20);
Data views allow you to define multiple, pre-filtered views of the same data source which can be toggled between via the list view UI. This can be useful when entities exist in different states and you want a way to toggle between them.
Adds a data view with the given name and where clause filter expression. Expression must be a boolean
expression.
// Example
listViewConfig.AddDataView("Active", p => p.IsActive);
Sets the list views data views builder which allows you to define the data views dynamically at run time. See Data Views Builders API documentation for more info.
// Example
listViewConfig.SetDataViewsBuilder<PersonDataViewsBuilder>();
Adds a bulk action of the given type to the list view. See Bulk Actions API documentation for more info.
// Example
listViewConfig.AddBulkAction<ExportBulkAction>();
Adds the provided bulk action to the list view. See Bulk Actions API documentation for more info.
// Example
listViewConfig.AddBulkAction(new ExportBulkAction());
By default the list view will use the built in Umbraco table and grid list view layouts however you can provide your own custom layouts. If you provide a layout, then it will replace the defaults, so if you still want the defaults as options, you’ll need to add these again explicitly. To do this, you’ll need to call AddLayout<TListViewLayoutType>
for each one you want to add with a TListViewLayoutType
parameter of FluidityTableListViewLayout
or FluidityGridListViewLayout
.
Adds a list view layout of the given type to the list view. See List View Layouts API documentation for more info.
// Example
listViewConfig.AddLayout<MyCustomListViewLayout>();
Adds the provided list view layout to the list view. See List View Layouts API documentation for more info.
// Example
listViewConfig.AddLayout(new MyCustomListViewLayout());
Adds the given property to the list view.
// Example
listViewConfig.AddField(p => p.FirstName, fieldConfig => {
...
});
Sets the heading for the list view field.
// Example
fieldConfig.SetHeading("First Name");
Sets the format expression for the list view field.
// Example
fieldConfig.SetFormat((v, p) => $"{v} years old");