Yii method of replacing Cgridview text box with drop-down box, yiicgridview_php tutorial

Source: Internet
Author: User

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 ...

  • 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.