CGridView Works For Admin User, But Not Other Users

I have found that my admin users can sort and filter CGridView data tables just fine. But it fails to work for non-admin users. <_< When I first pull up the page:

[indent]admin shows: "Displaying 1-[color="#009900"]20[/color] of 21 result(s)."

non-admin shows: "Displaying 1-[color="#990000"]21[/color] of 21 result(s)."[/indent]

Note that the [color="#009900"]green[/color] reflects the correct text and [color="#990000"]red[/color] the incorrect.

If I filter by a field that should result in no results:

[indent]admin shows: nothing (which is correct)

non-admin shows: "[color="#990000"]Displaying -20-0 of 0 result(s).[/color]" and the list does not change.


If I click on a column to sort, the admin sorts correctly, the non-admin shows the sorting icon next to the column header, but the data does not change sort order.


   $this->widget('zii.widgets.grid.CGridView', array(






         array('name'=>'nProductID', 'htmlOptions'=>array('width'=>20)),

         array('name'=>'nProductClassID', 'value'=>'$data->ClassR->strProductClass', 'htmlOptions'=>array('width'=>60), 'filter'=>CHtml::listData(ProductClass::model()->findAll(array('order'=>'strProductClass')), 'nProductClassID', 'strProductClass')),

         array('name'=>'strProductCode', 'htmlOptions'=>array('width'=>55)),

         array('name'=>'strSKU', 'htmlOptions'=>array('width'=>90)),

         array('name'=>'strTitle', 'value'=>'$data->strTitle', 'htmlOptions'=>array('style'=>'text-align: left')),

         array('name'=>'curPrice', 'value'=>'"$".$data->curPrice', 'htmlOptions'=>array('width'=>40)),

         array('name'=>'nPublisherID', 'value'=>'$data->PublisherR->strPublisher', 'htmlOptions'=>array('width'=>150, 'style'=>'text-align: left'), 'filter'=>Publisher::filterList()),

         array('name'=>'nPDFStatusID', 'value'=>'$data->PDFStatusR->strPDFStatus', 'htmlOptions'=>array('width'=>60, 'style'=>'text-align: left'), 'filter'=>CHtml::listData(PDFStatus::model()->findAll(array('order'=>'nPDFStatusID')), 'nPDFStatusID', 'strPDFStatus')),

         array('name'=>'bHidden', 'value'=>'boolAsYesNo($data->bHidden, false)', 'htmlOptions'=>array('width'=>40), 'filter'=>array(0=>"No", 1=>"Yes")),

         array('name'=>'dateAdded', 'value'=>'dateFormat("Y-m-d", $data->dateAdded, "Unknown")', 'htmlOptions'=>array('width'=>70)),







   public function search() {

      $criteria = new CDbCriteria;

      $userObj  = Yii::app()->getModule('user');

      $user     = $userObj->user();

      $pubid    = ($userObj->isAdmin()) ? $this->nPublisherID : $user->nPublisherID;

      $criteria->with = array('ClassR', 'PublisherR', 'PDFStatusR');











      return new CActiveDataProvider($this, array(





I am aware that I am sorting in the model based on whether the user is an admin or not. This was my first thought. Even if I take out this code, it still functions the same way. ???

Any thoughts?

starring at your code and trying to figure out what you’re trying to do.

is this what your want?

in search function:

//      $pubid    = ($userObj->isAdmin()) ? $this->nPublisherID : $user->nPublisherID;

      if (!$userObj->isAdmin())


Your are using AJAX to update the view. Did you check the non-admin users had access to the AJAX actions? Check in your controller that there is no filterAccess. Then launch a developer toolbar in your web browser (à la firebug) and see if the AJAX requests are successful.

Thank you for your suggestion. Firebug show that it is getting a valid AJAX request back. What it gets back just does not change from what is seen on the screen, in other words, it is the same list. I will keep digging deeper.

I figured this out… it had to do with something I was doing in the findAll function in the model. I was overriding the incoming condition variable for non-admins. Altered that part and it started working right.