Cgridview displays data in tabular form, Cgridview also supports paging and sorting, Cgridview the most basic usage and ListView types, and also by setting data provider, usually cactivedataprovider.
Modify the previous example Yii Framework development Tutorial (a) Zii component-detailview example, ListView should be the GridView:
<?php $this->widget (' Zii.widgets.grid.CGridView ', Array (
' Dataprovider ' => $dataProvider,
' Ajaxupdate ' =>false,
' template ' => ' {pager}{summary}{items}{pager} ',
);?>
The results appear as follows:
You can see that the GridView defaults to displaying all the fields and displays the fields in the default format, and you can do this by configuring the Cgridview::columns property if you want to control the display and formatting of the fields. Each column of the GridView is a Cgridcolumn object:
Cgridcolumn is the base class for all grid list items, and each instance of the table can have a header, multiple data units, and an optional footer cell.
Cbuttoncolumn indicates that the cell is one or more buttons, the default display of three buttons, "View", "Update" and "delete" can be changed by setting buttons and template.
Ccheckboxcolumn indicates that the cell is a checkbox, supports read-only, single or multiple selections, and modifies the selectablerows by configuring the
Cdatacolumn indicates that the unit is data or an expression, by configuring name or value, which represents the property name of the data model, the latter code a PHP expression.
Clinkcolumn represents a hyperlink that sets the link by configuring a label, URL, or ImageUrl.