Yii Framework Forum: CGridView filter control - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CGridView filter control Rate Topic: -----

#1 User is offline   genady 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 04-July 10

Posted 16 July 2010 - 01:15 PM

By default, Grid creates filter control in a form of text box. For one of my columns I want to replace that with
DropDownList selector. How can I do this?

Thanks.
0

#2 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,020
  • Joined: 30-October 09
  • Location:UK

Posted 16 July 2010 - 03:27 PM

array(
	'name'=>'attribute',
	'value'=>'$data->attribute',
	'filter'=>array(<data options>),
),

0

#3 User is offline   omko 

  • Advanced Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 13-July 10
  • Location:Київ - мать городов русских.

Posted 19 July 2010 - 08:16 AM

For example

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'properties-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'title',
		array(
			'name'=>'state_id',
			'value'=>'$data->state->name',
			'filter'=> CHtml::listData(States::model()->findAll(), 'id', 'name'),
		),
		'year_build',
		'city',
		array(
			'name'=>'featured',
			'value'=> $model->featured,
			'filter'=>array(0=>"No", 1=>"Yes"),
		),
		array(
			'name'=>'type_id',
			'value'=>'$data->type->name',
			'filter'=> CHtml::listData(Types::model()->findAll(), 'id', 'name'),
		),
		array(
			'name'=>'listing_type_id',
			'value'=> $model->listing_type_id,
			'filter'=> CHtml::listData(ListingTypes::model()->findAll(), 'id', 'name'),
		),
		'price',
		'user.username',
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>

0

#4 User is offline   jogasa21 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 09-March 11
  • Location:Costa Rica / Cambodia

Posted 18 August 2011 - 03:33 AM

View Postomko, on 19 July 2010 - 08:16 AM, said:



Thank you omko. This is the answer I was looking for.

Cheers.
0

#5 User is offline   sonam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 10-September 11

Posted 14 November 2011 - 05:02 AM

filters are not working please help
0

#6 User is offline   enfield 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 288
  • Joined: 12-January 11

Posted 14 November 2011 - 02:18 PM

View Postsonam, on 14 November 2011 - 05:02 AM, said:

filters are not working please help


oh man, sorry to hear that!
0

#7 User is offline   Giancarlo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 242
  • Joined: 20-December 11
  • Location:Turin, Italy

Posted 15 October 2012 - 10:17 AM

Hi,
i have this problem:

an field has this values: (0,1,2,3,4,5)

It's possible create an filter that show
all records > 0

?
Posted Image Non preoccuparti, è dentro il monitor!

Sapevi che cercando su google yii + "la funzione su cui stai impazzendo", trovi quasi sempre dei buoni indizi in italiano, per risolvere i tuoi problemi, senza perdere tempo a postare?
0

#8 User is offline   Giancarlo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 242
  • Joined: 20-December 11
  • Location:Turin, Italy

Posted 16 October 2012 - 05:03 AM

For to show all records > 0:
'filter'=>array('<1'=>'empty','>0'=>'full'),

but how can I add this item to the following filter?
'filter'=> CHtml::listData(States::model()->findAll(), 'id', 'name'),

Posted Image Non preoccuparti, è dentro il monitor!

Sapevi che cercando su google yii + "la funzione su cui stai impazzendo", trovi quasi sempre dei buoni indizi in italiano, per risolvere i tuoi problemi, senza perdere tempo a postare?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users