CBaseListView
CBaseListView is the base class for
CListView and
CGridView.
CBaseListView implements the common features needed by a view wiget for rendering multiple models.
Property Details
the data provider for the view.
public string $emptyText;
the message to be displayed when dataProvider does not have any data.
public boolean $enablePagination;
whether to enable pagination. Note that if the IDataProvider::pagination property
of dataProvider is false, this will be treated as false as well. When pagination is enabled,
a pager will be displayed in the view so that it can trigger pagination of the data display.
Defaults to true.
public boolean $enableSorting;
whether to enable sorting. Note that if the IDataProvider::sort property
of dataProvider is false, this will be treated as false as well. When sorting is enabled,
sortable columns will have their headers clickable to trigger sorting along that column.
Defaults to true.
public array $htmlOptions;
the HTML options for the view container tag.
public string $itemsCssClass;
the CSS class name for the container of all data item display. Defaults to 'items'.
public string $loadingCssClass;
the CSS class name that will be assigned to the widget container element
when the widget is updating its content via AJAX. Defaults to 'loading'.
public array $pager;
the configuration for the pager. Defaults to array('class'=>'CLinkPager').
public string $pagerCssClass;
the CSS class name for the pager container. Defaults to 'pager'.
public string $summaryCssClass;
the CSS class name for the summary text container. Defaults to 'summary'.
public string $summaryText;
the summary text template for the view. These tokens are recognized and will be replaced
with the corresponding values:
- {start}: the starting row number (1-based) currently being displayed
- {end}: the ending row number (1-based) currently being displayed
- {count}: the total number of rows
- {page}: the page number (1-based) current being displayed, available since version 1.1.3
- {pages}: the total number of pages, available since version 1.1.3
public string $tagName;
the tag name for the view container. Defaults to 'div'.
public string $template;
the template to be used to control the layout of various sections in the view.
These tokens are recognized: {summary}, {items} and {pager}. They will be replaced with the
summary text, the items, and the pager.
Method Details
Initializes the view.
This method will initialize required property values and instantiate columns objects.
|
public void registerClientScript()
|
Registers necessary client scripts.
This method is invoked by run.
Child classes may override this method to register customized client scripts.
|
public void renderContent()
|
Renders the main content of the view.
The content is divided into sections, such as summary, items, pager.
Each section is rendered by a method named as "renderXyz", where "Xyz" is the section name.
The rendering results will replace the corresponding placeholders in template.
|
public void renderEmptyText()
|
Renders the empty message when there is no data.
|
abstract public void renderItems()
|
Renders the data items for the view.
Each item is corresponding to a single data model instance.
Child classes should override this method to provide the actual item rendering logic.
Renders the key values of the data in a hidden tag.
|
public void renderPager()
|
Renders the pager.
|
protected string renderSection(array $matches)
|
| $matches |
array |
the matches, where $matches[0] represents the whole placeholder,
while $matches[1] contains the name of the matched placeholder. |
| {return} |
string |
the rendering result of the section |
Renders a section.
This method is invoked by renderContent for every placeholder found in template.
It should return the rendering result that would replace the placeholder.
|
public void renderSummary()
|
Renders the summary text.
Renders the view.
This is the main entry of the whole view rendering.
Child classes should mainly override renderContent method.