CListView can be used to display lists, CListView supports the use of custom view templates to display lists of records, so it is very flexible to display the table of data, which is a bit like the Android ListView:-). CListView supports paging and sorting, pagination and sorting support using AJAX implementations to improve page responsiveness. The use of CListView is required through dataprovider, usually using Cactivedataprovider. This example modifies the Yii Framework development tutorial (26) Database-active record example, but in order to display pagination, we use the Customer database table, which shows 10 records per page. Modify the default view protected/views/site/index.php, using the ListView component. [PHP] Widget (' Zii.widgets.CListView ', Array (' dataprovider ' = = $dataProvider, ' ajaxupdate ' =>false, ' template ' = '} ' { Sorter}{pager}{summary}{items}{pager} ', ' itemview ' = ' _view ', ' Pager ' =>array (' maxbuttoncount ' = ' 7 ',), ' Sortableattributes ' =>array (' FirstName ', ' LastName ', ' country ',),);?> Widget (' Zii.widgets.CListView ', Array (' dataprovider ' = = $dataProvider, ' ajaxupdate ' =>false, ' template ' = '} ' { Sorter}{pager}{summary}{items}{pager} ', ' itemview ' = ' _view ', ' Pager ' =>array (' maxbuttoncount ' = ' 7 ',), ' Sortableattributes ' =>array (' FirstName ', ' LastName ', ' country ',),),?> parameter Template Configuration page displays templates, supported parameters are {summary}, { Sorter}, {items} and {pager}, respectively, correspond to the summary, sort, list item, and pagination control of the ListView. The parameter Itemview indicates the view display for each list item. This example uses site/_view.php, which is defined as follows: [PHP]
FirstName. ' ' . $data->lastname);? >
Getattributelabel (' Company '); Company);?>
Getattributelabel (' Address '); Format->formaturl ($data->address);?>
Getattributelabel (' country ')); Country);?>
Getattributelabel (' Email ')); Format->formatemail ($data->email);?>
FirstName. ' ' . $data->lastname);? >
Getattributelabel (' Company '); Company);?>
Getattributelabel (' Address '); Format->formaturl ($data->address);?>
Getattributelabel (' country ')); Country);?>
Getattributelabel (' Email ')); Format->formatemail ($data->email);?>
Then modify the Indexaction method of the Sitecontroller: [PHP] public Function Actionindex () {$dataProvider =new cactivedataprovider (' Customer ', Array (' Pagination ' =>array (' pageSize ' =>10, ' pagevar ' = ' page ',), ' Sort ' =>array (' Defaultorder ' = ' Lastname ',),)); $this->render (' index ', array (' dataprovider ' = $dataProvider,)); The Public Function Actionindex () {$dataProvider =new cactivedataprovider (' Customer ', Array (' Pagination ' =>array (' PageSize ' =>10, ' pagevar ' = ' page ', ', ' Sort ' =>array (' defaultorder ' = ' Lastname ', '), $this->render (' Index ', array (' dataprovider ' = $dataProvider,));} The results appear as follows:
http://www.bkjia.com/PHPjc/477838.html www.bkjia.com true http://www.bkjia.com/PHPjc/477838.html techarticle CListView can be used to display lists, CListView supports the use of custom view templates to display lists of records, so it is very flexible to display the table of data, which is a bit like the android Li ...