php - How to provide selected rows to cgridview to display and at same time provide search for columns -



php - How to provide selected rows to cgridview to display and at same time provide search for columns -

here using cactivedataprovider pass selected rows giving status , in view displaying in cgridview columns working fine @ same time should provide search columns unable provide search can 1 help. here sample code

controller code public function actionshow($id) { $model=new studentresult('search'); $model->unsetattributes(); // clear default values if(isset($_get['studentresult'])) $model->attributes=$_get['studentresult']; $dataprovider=new cactivedataprovider('studentresult', array( 'criteria'=>array( 'condition'=>"profileid=$id", ), 'pagination'=>array( 'pagesize'=>20, ), )); $this->render('show',array( 'model'=>$model, 'dataprovider' => $dataprovider, )); } view code <div class="search-form" style="display:none"> <?php $this->renderpartial('_search',array( 'model'=>$model, )); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.cgridview', array( 'id'=>'student-result-grid', 'dataprovider'=>$dataprovider, 'filter'=>$model, 'columns'=>array( 'id', 'modulecode', 'moduletitle', 'modulecredits', 'grade', 'creditsobtain', 'semester', /* 'points', 'profileid', 'createdon', 'lastmodifiedon', 'lastmodifiedby', */ array( 'class'=>'cbuttoncolumn', ), ), )); ?>

so in view displaying info giving 'dataprovider' => $dataprovider values displaying correctly search not working if provide 'dataprovider' => $model->search(); whole values displaying , search working

here can pass selected row action want.

<?php $this->widget('zii.widgets.grid.cgridview', array('id' =>'list-grid', 'dataprovider'=>$dataprovider->search(), 'filter' =>$dataprovider, 'columns'=>array( 'id', 'modulecode', 'moduletitle', 'modulecredits', 'grade', 'creditsobtain', 'semester', 'action'=>array( 'class'=>'cbuttoncolumn', 'header' => 'edit', 'template' => '{edit}', 'buttons' => array( 'edit' =>array( 'label' => 'edit', 'imageurl'=>yii::app()>request>baseurl.'path/to/your/image',// can utilize other options 'url' => 'yii::app()->createurl("/controller/action/id/".someencryption-to-hide-id($data->id))',), 'visible' => true, ), ), ), )); ?>

your controller action goes this:

public function actionyouraction() { $dataprovider = new modelname('search'); $dataprovider -> unsetattributes(); // clear default values if (isset($_get['modelname'])) { $dataprovider -> attributes = $_get['modelname']; } $this -> render('viewpage', array('dataprovider' => $dataprovider, )); }

and model criteria be:

public function search() { $criteria -> compare('id', $this -> id); ... homecoming new cactivedataprovider($this, array('criteria' => $criteria, )); }

let me know getting right.

php yii-extensions yii

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -