php - search function in yii gridview -
i have project implemented in yii. grid view search function not working in server. in localhost grid view search function working. issue in that. please suggest me should change.
my recipe controller:
public function actionadmin() { $model=new recipe('search'); $model->unsetattributes(); // clear default values if(isset($_get['recipe'])) $model->attributes=$_get['recipe']; $this->render('admin',array( 'model'=>$model, )); }
my model part:
public function search() { // warning: please modify following code remove attributes // should not searched. $criteria=new cdbcriteria; $pagination=array('pagesize'=>'10'); $criteria->compare('recipe_id',$this->recipe_id); $criteria->compare('posted_id',$this->posted_id,true); $criteria->compare('name',$this->name,true); $criteria->compare('type',$this->type); $criteria->compare('cuisinename',$this->cuisinename); $criteria->compare('course_id',$this->course_id); $criteria->compare('details',$this->details,true); $criteria->compare('serving_size',$this->serving_size,true); $criteria->compare('calorie_count',$this->calorie_count); $criteria->compare('preparation_time',$this->preparation_time); $criteria->compare('cooking_instructions',$this->cooking_instructions,true); $criteria->compare('garnishing_instructions',$this->garnishing_instructions,true); $criteria->compare('serving_instructions',$this->serving_instructions,true); $criteria->compare('recipe_image',$this->recipe_image,true); $criteria->compare('recipe_small_image',$this->recipe_small_image,true); $criteria->compare('status',$this->status,true); $criteria->compare('posting_time',$this->posting_time,true); $criteria->compare('plike',$this->plike); $criteria->compare('pdislike',$this->pdislike); $criteria->compare('images',$this->images,true); $criteria->compare('ingredient_typeid',$this->ingredient_typeid,true); return new cactivedataprovider($this, array( 'criteria'=>$criteria,'pagination'=>$pagination )); }
my view part:
<?php $this->widget('zii.widgets.grid.cgridview', array( 'id'=>'mygridview', 'dataprovider'=>$model->search(), 'filter'=>$model, 'columns'=>array( //'id', 'name', array( 'class'=>'cbuttoncolumn','template'=>'{update}{delete}', ), ), )); ?>
handle javascript following way, there no double jquery problem after this, add other js in 'js'
array
$baseurl = yii::app()->baseurl; $cs = yii::app()->clientscript; $cs->scriptmap = array('jquery.min.js'=>$baseurl.'/js/jquery-2.0.3.min.js', 'jquery.js'=>$baseurl.'/js/jquery-2.0.3.min.js'); $cs->registercorescript('jquery'); yii::app()->clientscript->addpackage('other-required-scripts', array( 'baseurl'=>$baseurl, 'js'=>array( "js/abc.js", "js/bcd.js", //... ), 'depends'=>array('jquery') )); yii::app()->clientscript->registerpackage('other-required-scripts');
Comments
Post a Comment