Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CollectionView

CollectionView is a base class for widgets displaying data from data provider such as ListView and GridView.

It provides features like sorting, paging and also filtering the data.

For more details and usage information on CollectionView, see the guide article on data widgets.

author

Mahesh S Warrier https://github.com/codespede

Hierarchy

Index

Constructors

Properties

_models: Model[] = []
dataProvider: DataProvider
var

\yii\data\DataProviderInterface the data provider for the view. This property is required.

emptyText: string | false

The HTML content to be displayed when dataProvider does not have any data. When this is set to false no extra HTML content will be generated. The default value is the text "No results found."

see

showOnEmpty

see

emptyTextOptions

emptyTextOptions: {} = ...

Type declaration

  • [key: string]: any
enablePjax: boolean = true

Whether to enable Pjax on this widget.

initialization: Promise<void>

A Promise which resolves when this Component has been successfully initialized.

layout: string = '{summary}\n{items}\n{pager}'

The layout that determines how different sections of the list view should be organized. The following tokens will be replaced with the corresponding section contents:

  • {summary}: the summary section. See [[renderSummary()]].
  • {items}: the list items. See [[renderItems()]].
  • {sorter}: the sorter. See [[renderSorter()]].
  • {pager}: the pager. See [[renderPager()]].
options: {} = ...

The HTML attributes for the container tag of the list view. The "tag" element specifies the tag name of the container element and defaults to "div".

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
pager: LinkPager

The configuration for the pager widget. By default, LinkPager will be used to render the pager. You can use a different widget class by configuring the "class" property. Note that the widget must support the pagination property which will be populated with the [[DataProvider.pagination|pagination]] value of the dataProvider and will overwrite this value.

showOnEmpty: boolean = false

Whether to show an empty list view if dataProvider returns no data. The default value is false which displays an element according to the emptyText and emptyTextOptions properties.

sorter: LinkSorter

The configuration for the sorter widget. By default, LinkSorter will be used to render the sorter. You can use a different widget class by configuring the "class" property. Note that the widget must support the sort property which will be populated with the [[DataProvider.sort|sort]] value of the dataProvider and will overwrite this value.

summary: string

The HTML content to be displayed as the summary of the list view. If you do not want to show the summary, you may set it with an empty string.

The following tokens will be replaced with the corresponding values:

  • {begin}: the starting row number (1-based) currently being displayed
  • {end}: the ending row number (1-based) currently being displayed
  • {count}: the number of rows currently being displayed
  • {totalCount}: the total number of rows available
  • {page}: the page number (1-based) current being displayed
  • {pageCount}: the number of pages available
summaryOptions: {} = {}

The HTML attributes for the summary of the list view. The "tag" element specifies the tag name of the summary element and defaults to "div".

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
autoIdPrefix: string = 'w'

The prefix to the automatically generated widget IDs.

see

getId

counter: number = 0

A counter used to generate id for widgets.

internal

Methods

  • getId(autogenerate?: boolean): string
  • Returns the ID of the widget.

    Parameters

    • autogenerate: boolean = true

    Returns string

    ID of the widget.

  • init(): Promise<void>
  • registerAssets(): void
  • render(): Promise<string>
  • Renders a widget.

    throws

    InvalidArgumentException if the view file does not exist.

    Returns Promise<string>

    string the rendering result.

  • renderEmpty(): string
  • renderItems(): Promise<any>
  • renderPager(): Promise<string>
  • renderSection(name: string): Promise<string>
  • Renders a section of the specified name. If the named section is not supported, false will be returned.

    Parameters

    • name: string

      the section name, e.g., {summary}, {items}.

    Returns Promise<string>

    the rendering result of the section, or false if the named section is not supported.

  • renderSorter(): Promise<string>
  • renderSummary(): Promise<string>
  • run(): Promise<string>

Generated using TypeDoc