Skip to content
PHP Ecosystem
Explore

GridView

API reference › Debug › widgets › GridView

Renders a debugger grid whose footer sentence comes from the shared GridCount renderer.

PropertyTypeDescriptionDefined by
$afterRowClosureAn anonymous function that is called once AFTER rendering each data model. Default: null.yii\grid\GridView
$autoIdPrefix staticstringThe prefix to the automatically generated widget IDs. Default: 'w'.yii\base\Widget
$beforeRowClosureAn anonymous function that is called once BEFORE rendering each data model. Default: null.yii\grid\GridView
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$captionstringThe caption of the grid table Default: null.yii\grid\GridView
$captionOptionsarrayThe HTML attributes for the caption element. Default: [].yii\grid\GridView
$clientScriptarray|yii\web\client\ClientScriptInterface|nullClient script class to use for client-side validation. Default: null.yii\grid\GridView
$columnsarrayGrid column configuration. Default: [].yii\grid\GridView
$dataColumnClassstringThe default data column class if the class name is not explicitly specified when configuring a data column. Default: null.yii\grid\GridView
$dataProvideryii\data\DataProviderInterfaceThe data provider for the view. Default: null.yii\widgets\BaseListView
$emptyCellstringThe HTML display when the content of a cell is empty. Default: '&nbsp;'.yii\grid\GridView
$emptyTextstring|false|nullThe HTML content to be displayed when $dataProvider does not have any data. Default: null.yii\widgets\BaseListView
$emptyTextOptionsarrayThe HTML attributes for the emptyText of the list view. Default: ['class' => 'empty'].yii\widgets\BaseListView
$filterErrorOptionsarrayThe options for rendering every filter error message. Default: ['class' => 'field-error'].yii\grid\GridView
$filterErrorSummaryOptionsarrayThe options for rendering the filter error summary. Default: ['class' => 'error-summary'].yii\grid\GridView
$filterModelyii\base\Model|nullThe model that keeps the user-entered filter data. Default: null.yii\grid\GridView
$filterOnFocusOutboolWhatever to apply filters on losing focus. Default: true. Available since 2.0.16.yii\grid\GridView
$filterPositionstringWhether the filters should be displayed in the grid view. Default: self::FILTER_POS_BODY.yii\grid\GridView
$filterRowOptionsarrayThe HTML attributes for the filter row element. Default: ['class' => 'filters'].yii\grid\GridView
$filterSelectorstring|Closure(string, string): stringJQuery selector for selecting filter input fields. Default: null.yii\grid\GridView
$filterUrlstring|array|nullThe URL for returning the filtering result. Url::to() will be called to normalize the URL. Default: null.yii\grid\GridView
$footerRowOptionsarrayThe HTML attributes for the table footer row. Default: [].yii\grid\GridView
$formatterarray|yii\i18n\Formatter|nullThe formatter used to format model attribute values into displayable texts. Default: null.yii\grid\GridView
$headerRowOptionsarrayThe HTML attributes for the table header row. Default: [].yii\grid\GridView
$idstringId of the widget.yii\base\Widget
$layoutstringThe layout that determines how different sections of the grid view should be organized. Default: "{summary}\n{items}\n{pager}".yii\grid\GridView
$optionsarrayThe HTML attributes for the container tag of the grid view. Default: ['class' => 'grid-view'].yii\grid\GridView
$overrideFilterSelectorboolIf set, $filterSelector overrides the default selector of ’#$id input, #$id select’ (where $id is the filter row ID) rather than being added to it. Default: false.yii\grid\GridView
$pagerarrayThe configuration for the pager widget. Default: [].yii\widgets\BaseListView
$placeFooterAfterBodyboolWhether to place footer after body in DOM if $showFooter is true Default: false. Available since 2.0.14.yii\grid\GridView
$rowOptionsarray|ClosureThe HTML attributes for the table body rows. Default: [].yii\grid\GridView
$showFooterboolWhether to show the footer section of the grid table. Default: false.yii\grid\GridView
$showHeaderboolWhether to show the header section of the grid table. Default: true.yii\grid\GridView
$showOnEmptyboolWhether to show the grid view if $dataProvider returns no data. Default: true.yii\grid\GridView
$sorterarrayThe configuration for the sorter widget. Default: [].yii\widgets\BaseListView
$summarystring|nullThe HTML content to be displayed as the summary of the list view. Default: null.yii\widgets\BaseListView
$summaryOptionsarrayThe HTML attributes for the summary of the list view. Default: ['class' => 'summary'].yii\widgets\BaseListView
$tableOptionsarrayThe HTML attributes for the grid table element. Default: [].yii\grid\GridView
$viewyii\web\ViewThe view object that can be used to render views or view files.yii\base\Widget
$viewPath read-onlystringThe directory containing the view files for this widget.yii\base\Widget
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
afterRun()This method is invoked right after a widget is executed.yii\base\Widget
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
beforeRun()This method is invoked right before the widget is executed.yii\base\Widget
begin() staticBegins a widget.yii\base\Widget
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
end() staticEnds a widget.yii\base\Widget
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getId()Returns the ID of the widget.yii\base\Widget
getView()Returns the view object that can be used to render views or view files.yii\base\Widget
getViewPath()Returns the directory containing the view files for this widget.yii\base\Widget
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
init()Initializes the grid view.yii\grid\GridView
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
render()Renders a view.yii\base\Widget
renderCaption()Renders the caption element.yii\grid\GridView
renderColumnGroup()Renders the column group HTML.yii\grid\GridView
renderEmpty()Renders the HTML content indicating that the list view has no data.yii\widgets\BaseListView
renderErrors()Renders validator errors of filter model.yii\grid\GridView
renderFile()Renders a view file.yii\base\Widget
renderFilters()Renders the filter.yii\grid\GridView
renderItems()Renders the data models for the grid view.yii\grid\GridView
renderPager()Renders the pager.yii\widgets\BaseListView
renderSection()Renders a section of the specified name.yii\grid\GridView
renderSorter()Renders the sorter.yii\widgets\BaseListView
renderSummary()Renders the row-count sentence for the rows currently on screen.GridView
renderTableBody()Renders the table body.yii\grid\GridView
renderTableFooter()Renders the table footer.yii\grid\GridView
renderTableHeader()Renders the table header.yii\grid\GridView
renderTableRow()Renders a table row with the given data model and key.yii\grid\GridView
run()Runs the widget.yii\grid\GridView
setId()Sets the ID of the widget.yii\base\Widget
setView()Sets the view object to be used by this widget.yii\base\Widget
trigger()Triggers an event.yii\base\Component
widget() staticCreates a widget instance and runs it.yii\base\Widget
createDataColumn() protectedCreates a DataColumn object based on a string in the format of “attribute:format:label”.yii\grid\GridView
getClientOptions() protectedReturns the options for the grid view JS widget.yii\grid\GridView
guessColumns() protectedThis function tries to guess the columns to show from the given data if $columns are not explicitly specified.yii\grid\GridView
initColumns() protectedCreates column objects and initializes them.yii\grid\GridView
EventTypeDescriptionDefined by
EVENT_INITyii\base\EventAn event that is triggered when the widget is initialized via init(). Event name: 'init'. Available since 2.0.11.yii\base\Widget
EVENT_BEFORE_RUNyii\base\WidgetEventAn event raised right before executing a widget. Event name: 'beforeRun'. Available since 2.0.11.yii\base\Widget
EVENT_AFTER_RUNyii\base\WidgetEventAn event raised right after executing a widget. Event name: 'afterRun'. Available since 2.0.11.yii\base\Widget
public function renderSummary(): string

Renders the row-count sentence for the rows currently on screen.

Derives the counters the way BaseListView::renderSummary() does: the paginator’s offset opens the range and the number of rows rendered on the page closes it, while disabled pagination reports the whole set as a single page. An empty page reports 0-0, matching the shared renderer instead of collapsing to an empty string.

Returns

string: Rendered row-count sentence.