Yii Framework Forum: Filter In Cgridview Returns No Results - Yii Framework Forum

Jump to content

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

Filter In Cgridview Returns No Results Rate Topic: -----

#1 User is offline   Anthony Gough 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 29-October 12

Posted 04 December 2012 - 01:03 AM

I placed a filter into a CGridView and it creates a drop down list of all business names however when I select a value in the drop down no results are returned. The admin view is for the Client model and the code is
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'client-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'provider_id',
		array(
			'name'=>'business_name',
			'filter'=>CHtml::listData(Client::model()->findAll(array('condition'=>'active=1',
			'order'=>'business_name ASC')),
			'id','business_name'),
			'value'=>'CHtml::encode($data->business_name)',
			),
		'business_address',
		'business_suburb',
		'business_postcode',
......

The drop down lists all the Client business names however when I select a Business Name from the drop down NO results are returned from the search. Any advice would be appreciated.

NOTE:
If I use the following code and generate a drop do list of id's then the search function works.
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'client-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'provider_id',
		array(
			'name'=>'business_name',
			'filter'=>CHtml::listData(Client::model()->findAll(array('condition'=>'active=1',
			'order'=>'business_name ASC')),
			'business_name','id'),
			'value'=>'CHtml::encode($data->business_name)',
			),
		'business_address',
		'business_suburb',
		'business_postcode',
......


It seems the business name as a string is not returning a match.
0

#2 User is offline   Anthony Gough 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 29-October 12

Posted 04 December 2012 - 01:55 AM

The answer is
array(
			'name'=>'business_name',
			'filter'=>CHtml::listData(Client::model()->findAll(array('condition'=>'active=1',
			'order'=>'business_name ASC')),
			'business_name','business_name'),
			'value'=>'CHtml::encode($data->business_name)',
			),

For the filter (value,value)
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