Yii cgridview make custom drop down filters, Yii cgridview set row color based on a condition, Yii cgridview add time picker in filter, Yii cgridview add drop down in colum values
Here is an example how you can make custom drop down filters in YII cgridview:$this->widget('zii.widgets.grid.CGridView', array( 'id' => 'card-applications-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'reinstallDatePicker', 'rowCssClassExpression'=>'($data->is_updated==1)?"application_updated":"application_not_updated"', 'columns' => array( array( 'name'=>'applicant_id', 'value'=>'$data->applicant_id', 'filter'=> CHtml::listData($model->findAll(), 'applicant_id', 'applicant_id') ), array( 'name' => 'applicant_date', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array( 'model'=>$model, 'attribute'=>'applicant_date', 'language' => 'ja', 'i18nScriptFile' => 'jquery.ui.datepicker-ja.js', // (#2) 'htmlOptions' => array( 'id' => 'datepicker_for_applicant_date', 'size' => '30', ), 'options' => array( 'showAnim' => 'fold', 'dateFormat'=>'yy-mm-dd', 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1950:2013', 'minDate' => '1950-01-01', // minimum date //'maxDate' => '2013-01-' ), 'defaultOptions' => array( 'showAnim' => 'fold', 'dateFormat'=>'yy-mm-dd', 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1950:2013', 'minDate' => '1950-01-01', // minimum date //'maxDate' => '2013-01-' ), ), true), // (#4) ), 'applicant_time', array( 'name'=>'appCreator_id', 'value'=>'$data->appCreator->user_name', 'filter' => CHtml::listData(Users::model()->findAll('user_type="appCreator"'), 'user_id', 'user_name' ) ), array( 'name'=>'apllicant_payment_status', 'value'=>'CardApplications::getPaidUnpaid($data->apllicant_payment_status)', 'filter'=>CHtml::listData(CardApplications::getPaidUnpaids(), 'id', 'title'), ), array( 'name'=>'applicant_activation_status', 'value'=>'CardApplications::getActivationStatus($data->applicant_activation_status)', 'filter'=>CHtml::listData(CardApplications::getActivationStatuss(), 'id', 'title'), ), array( 'name'=>'applicant_status', 'value'=>'CardApplications::getApplicationStatus($data->applicant_status)', 'filter'=>CHtml::listData(CardApplications::getApplicationStatuss(), 'id', 'title'), ), array( 'name'=>'application_payment_method', 'value'=>'CardApplications::getApplicationPaymentMethod($data->application_payment_method)', 'filter'=>CHtml::listData(CardApplications::getApplicationPaymentMethods(), 'id', 'title'), ), array( 'name'=>'application_delivery_method', 'value'=>'CardApplications::getApplicationDeliveryMethod($data->application_delivery_method)', 'filter'=>CHtml::listData(CardApplications::getApplicationDeliveryMethods(), 'id', 'title'), ), array( 'name'=>'applicant_courrier_status', 'value'=>'CardApplications::getApplicationCourrierStatus($data->applicant_courrier_status)', 'filter'=>CHtml::listData(CardApplications::getApplicationCourrierStatuss(), 'id', 'title'), ), array( //'name'=>'renew', 'header'=>'renew', 'value'=>'CHtml::checkBox("renew", false)', 'type'=>'raw', ), array( 'name'=>'applicant_service_id', 'value'=> 'ServiceTypes::model()->findByPk($data->applicant_service_id)->service_name' ), 'applicant_sex', 'applicant_profession', 'applicant_name', 'applicant_sur_name', 'applicant_fathers_name', 'applicant_dob', 'applicant_identifier', 'applicant_social_security', 'applicant_job', 'applicant_afm', array( 'name'=>'applicant_doy', 'value'=> '$data->applicantDoy->doy_name' ), array( 'name'=>'applicant_country', 'value'=> '$data->applicantCountry->country_name' ), array( 'name'=>'applicant_region', 'value'=> '$data->applicantRegion->region_name' ), array( 'name'=>'applicant_county', 'value'=> '$data->applicantCounty->county_name' ), array( //'name'=>'applicant_dependants', 'header'=>'Dependants', 'value'=> "CHtml::dropDownList('','', CHtml::listData(CardApplications::getApplicationCourrierStatuss(), 'id', 'title'))", 'type' => 'raw', ), 'applicant_city', 'applicant_street_number', 'applicant_zip_code', 'applicant_landline', 'applicant_mobile_phone', 'applicant_email', 'applicant_user_name', 'applicant_password', 'applicant_way_of_receiving', 'applicant_desired_date_of_receipt', 'applicant_delivery_time_from', 'applicant_delivery_time_till', 'applicant_comments', //'applicant_status', //'applicant_activation_status', //'apllicant_payment_status', //'application_payment_method', array( 'class' => 'CButtonColumn', ), ), ));