Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments needs a filter #76

Open
cstdenis opened this issue Jun 10, 2013 · 2 comments
Open

Assignments needs a filter #76

cstdenis opened this issue Jun 10, 2013 · 2 comments

Comments

@cstdenis
Copy link

My database has a huge number of users -- couple hundred thousand (most do not have special permissions). The current pagination based system doesn't cut it, I need filters to find the users I want.

So I made them. Please review these small diffs and add them if you like.

--- widgets/AuthAssignmentNameColumn.php.orig   2013-01-20 03:04:31.000000000 -0800
+++ widgets/AuthAssignmentNameColumn.php        2013-06-10 00:32:59.000000000 -0700
@@ -32,4 +32,12 @@
        {
                echo CHtml::link(CHtml::value($data, $this->nameColumn), array('view', 'id'=>$data->{$this->idColumn}));
        }
+
+       /**
+        * Renders the filter cell content.
+        */
+       protected function renderFilterCellContent()
+       {
+               echo CHtml::activeTextField($this->grid->filter, $this->getNameColumn(), array('id'=>false));
+       }
 }
--- views/assignment/index.php.orig     2013-01-01 12:05:32.000000000 -0800
+++ views/assignment/index.php  2013-06-10 01:05:37.000000000 -0700
@@ -11,7 +11,8 @@

 <?php $this->widget('bootstrap.widgets.TbGridView', array(
     'type' => 'striped hover',
-    'dataProvider' => $dataProvider,
+    'filter' => $model,
+    'dataProvider' => $model->search(),
        'emptyText' => Yii::t('AuthModule.main', 'No assignments found.'),
        'template'=>"{items}\n{pager}",
     'columns' => array(
--- controllers/AssignmentController.php.orig   2013-01-11 18:54:10.000000000 -0800
+++ controllers/AssignmentController.php        2013-06-10 00:56:04.000000000 -0700
@@ -17,10 +17,13 @@
         */
        public function actionIndex()
        {
-               $dataProvider = new CActiveDataProvider($this->module->userClass);
+               $model = new $this->module->userClass('search');
+               $model->unsetAttributes();  // clear any default values
+               if(isset($_GET[$this->module->userClass]))
+                       $model->attributes=$_GET[$this->module->userClass];

                $this->render('index', array(
-                       'dataProvider' => $dataProvider
+                       'model' => $model
                ));
        }
@kachar
Copy link
Contributor

kachar commented Jun 19, 2013

You better make a pull request for this changes. It seems that they will be useful.

@cstdenis
Copy link
Author

Created pull request #81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants