Yii - Tbgridview Issue Sorting And Filtering

Hi,

I’m having a strange situation that is happening only with one of my views. I’m developing a small Yii application for my employee and I’ve already managed to create several different TbGridViews for different areas of the applications (Products / Services), all using somewhat the same structure. The issue here is happening only on a specific grid (Companies), where sorting, filtering and paging are not working. Everytime I try to sort, filter or change page, nothing happens (the grid shows the same information). Yet, if I delete a item, the grid refreshes correctly, as it should. I’ve searched the forums and saw several advices so far for this (criteria -> order, for instance, was one of the things that caused this issue, or ajaxRefresh -> disable) but, so far, none of these solutions work, since I don’t have bug that originated them in my code (or at least I cannot find it). I’ve compared the models / controllers and views between the grids that work and the grids that don’t work and they seem pretty much the same to me, so it should be working. So I was wondering if someone could shed some light into this. Below you can find the code:

View Code




<?php $this->widget('bootstrap.widgets.TbGridView',array(

	'id'=>'company-grid',

	'type'=>'bordered condensed',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		 array('name'=>'cid', 'header'=>'#'),

		 array('name'=>'name', 'header'=>'Name'),

		 array('name'=>'fiscalnumber', 'header'=>'Fiscal Nr.'),

		 array('name'=>'vat', 'header'=>'VAT'),

		 array('name'=>'year', 'header'=>'Year'),

		 array('name' => 'companycategoryid',

		 	   'filter' => CHtml::listData(Companycategory::model()->findAll(), 'cgid', 'category'),

               'value' => 'Helper::getCompanyCategory($data->companycategoryid)',

               'header'	=> 'Category'),

		 array('name'=>'importexportstatus', 'header'=>'Exports?'),

		 array(

			'class'=>'bootstrap.widgets.TbButtonColumn',

			'template'=>'{view}{update}{delete}',

			'buttons'=>array(

				'delete'=>array(

					'visible'=>'Yii::app()->user->isAdmin',

				)

			)

		),

	),

)); ?>



Controller Code (that calls the view)




public function actionIndex()

	{

		$model=new Company('search');	

		$model->unsetAttributes(); 

		if(isset($_GET['Company']))

			$model->attributes=$_GET['Company'];

			

		$this->render('index',array(

			'model'=>$model,

		));

	}



Model Code (search function)




public function search()

	{

		// @todo Please modify the following code to remove attributes that should not be searched.


		$criteria=new CDbCriteria;        

		if(!Yii::app()->user->isAdmin){

			$criteria->addSearchCondition('branchid',Yii::app()->user->id,true);

		}


		$criteria->compare('cid',$this->cid);

		$criteria->compare('name',$this->name,true);

		$criteria->compare('address',$this->address,true);

		$criteria->compare('countryid',$this->countryid);

		$criteria->compare('fiscalnumber',$this->fiscalnumber,true);

		$criteria->compare('vat',$this->vat,true);

		$criteria->compare('year',$this->year,true);

		$criteria->compare('legalrepresentative',$this->legalrepresentative,true);

		$criteria->compare('personofcontact',$this->personofcontact,true);

		$criteria->compare('email',$this->email,true);

		$criteria->compare('phone',$this->phone,true);

		$criteria->compare('fax',$this->fax,true);

		$criteria->compare('mobile',$this->mobile,true);

		$criteria->compare('site',$this->site,true);

		$criteria->compare('skype',$this->skype,true);

		$criteria->compare('other',$this->other,true);

		$criteria->compare('companycategoryid',$this->companycategoryid);

		$criteria->compare('companyprofile',$this->companyprofile,true);

		$criteria->compare('mainactivity',$this->mainactivity,true);

		$criteria->compare('activitycodes',$this->activitycodes,true);

		$criteria->compare('psdescription',$this->psdescription,true);

		$criteria->compare('importexportstatus',$this->importexportstatus,true);

		$criteria->compare('importexportareas',$this->importexportareas,true);

		$criteria->compare('numemployees',$this->numemployees,true);

		$criteria->compare('certification',$this->certification,true);

		

		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

	}



Any help with this would be welcome.

Thanks :)

Bump…

Anyone out there has any ideas?

Thanks :)

Is the data contains any special characters?

Hi.

Sorry for replying so late. Yes, it has some special characters (Portuguese language). Do you think that might be it? I’ll give it a try.

Thanks :)

Well solved it. It was, after all, a bug in an additional function that I created that was overriding a default function (findAll())

Thanks,