Yii the method of replacing the Cgridview text box with a drop-down box, Yiicgridview
In this paper, we describe the method that Yii changed the Cgridview text box to a drop-down box. Share to everyone for your reference. The implementation method is as follows:
Friends who use Yii know that the Cgridview in Yii is showing the text box by default, so how do we convert it to a drop-down box? This article analyzes the workaround.
By default, Cgridview generates a text box, but it's not friendly, and users often want to know what's optional, especially if the database has a digital ID, and we want to convert the numbers into readable text, just modify the "filter" property on the table header, for example:
Copy CodeThe code is as follows: <?php
$this->widget (' Zii.widgets.grid.CGridView ', Array (
' id ' = ' business-grid ',
' Dataprovider ' = $dataProvider,
' Filter ' = Business::model (),
' Columns ' =>array (
' business_id ',
' Name ',
' package_id ' = Array (
' Name ' = ' package_id ',
' Value ' = ' $data->package->package_title ',
' Filter ' = Chtml::listdata (Packages::model ()->findall (' order ' = ' package_title '), ' package_id ', ' Package_title ')
),
' User_ID ' =>array (
' Name ' = ' user_id ',
' Value ' = ' $data->user->name ',
' Filter ' = Chtml::listdata (Users::model ()->findall (' order ' = ' FirstName '), ' id ', ' name ')
),
' Categories ' = Array (
' Name ' = ' categories ',
' Value ' = ' $data->returnallcategories (",", false); ',
' Filter ' = Chtml::listdata (Categories::model ()->findall (Array (' order ' = ' category ') ', ' cat_id ', ' Category ')
),
' Keywords ' = array (
' Header ' = ' Keywords ',
' Value ' = ' $data->returnallkeywords (",", false); ',
),
' Links ' =>array (
' Header ' = ' Manage ',
' Type ' = ' raw ',
' Value ' = ' Chtml::link ' (Chtml::image (Yii::app ()->request->baseurl. /images/admin/approve.png "," approve "), Array (" Approve "," id "= = $data->business_id," Item "=" Business "), Array ("Class" = "Approve-link", "title" and "Approve business"). " ".
Chtml::link (Chtml::image (Yii::app ()->request->baseurl. /images/admin/reject.png "," reject "), Array (" Reject "," id "= = $data->business_id," Item "=" Business "), array ("Class" = "Reject-link", "title" = "Reject Business")) ',
),
),
));
The Generate Type drop-down box can be written like this:
Copy the Code Code as follows: ' Type ' =>array (
' Name ' = ' ' type ',
' Filter ' = $model->gettypeoptions (),
),
' Type ' =>array (
' Name ' = ' ' type ',
' Filter ' = $model->gettypeoptions (),
),
It is hoped that this article is helpful to the PHP program design based on YII framework.
http://www.bkjia.com/PHPjc/920977.html www.bkjia.com true http://www.bkjia.com/PHPjc/920977.html techarticle Yii changed the Cgridview text box to a drop-down box, Yiicgridview This example describes the method for Yii to change the Cgridview text box to a drop-down box. Share to everyone for your reference. Concrete implementation of the party ...