Cgridview displays data in tabular form, Cgridview also supports paging and sorting, Cgridview the most basic usage and ListView type, and also by setting data provider, usually cactivedataprovider.
Modify the previous example Yii Framework development Tutorial (zii) component-detailview example, the ListView is the GridView:
Widget (' Zii.widgets.grid.CGridView ', Array (' dataprovider ' = = $dataProvider, ' ajaxupdate ' =>false, ' template ' = > ' {pager}{summary}{items}{pager} ',?>);
You can see that the GridView default displays all fields and displays the fields in the default format, which you can configure by configuring the Cgridview::columns property if you need 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, each of which can have one header, multiple data units, and an optional footer cell.
Cbuttoncolumn means that the cell is one or more buttons, with three buttons displayed by default, "View", "Update" and "delete", which can be changed by setting the buttons and template.
Ccheckboxcolumn indicates that the cell is a checkbox, supports read-only, single-selection or multiple-selection, and is modified by configuring Selectablerows
Cdatacolumn indicates that the cell is either a data or an expression, by configuring name or value, which represents the property name of the data model, and the latter code is a PHP expression.
Clinkcolumn represents a hyperlink that sets a link by configuring a label, URL, or ImageUrl.
The Columns property of the GridView is redefined as follows:
Widget (' Zii.widgets.grid.CGridView ', array (' id ' = ' person-grid ', ' dataprovider ' = ' = $dataProvider, ' Htmloptions ' =>array (' style ' = ' width:740px '), ' pager ' =>array (' maxbuttoncount ' = ' 7 ',), ' columns ' = Array (' header ' = ' ' Name ', ' type ' = ' raw ', ' value ' = ' chtml::link ' ($data->firstname. " . $data->lastname, $this->grid->controller->createurl ("View", Array ("CustomerId" and $data- CustomerId)), ' company ', Array (' class ' = ' Clinkcolumn ', ' header ' = ' Email ', ' imageUrl ' = ' images/ Email.png ', ' labelexpression ' = ' $data->email ', ' urlexpression ' = ' mailto://'. $data->email ', ' Htmloptions ' =>array (' style ' = ' text-align:center '), Array (' class ' = ' cbuttoncolumn ', ' Deleteconfirmation ' + ' is you sure-delete this item? ',),),));? >
Click on the name to display the DetailView. ButtonColumn's update,search,delete did not add the corresponding view, it is left for you to add.
The above is the PHP Development Framework Yii Framework Tutorial (ZII) component-gridview sample content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!