PHP Development Framework Yii Framework Tutorial (+) Zii Component-gridview Example

Source: Internet
Author: User
Tags yii
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)!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.