我在Yii实施了项目。网格视图搜索功能在服务器中不起作用。在localhost网格视图搜索功能正常工作。那可能是什么问题。请建议我在哪里更改。
我的食谱控制器:
public function actionAdmin()
{
$model=new Recipe('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Recipe']))
$model->attributes=$_GET['Recipe'];
$this->render('admin',array(
'model'=>$model,
));
}
我的模特部分:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be 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
));
}
我的观点部分:
<?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}',
),
),
)); ?>
答案 0 :(得分:0)
按照以下方式处理你的javascript,此后不会出现双jquery问题,在'js'
数组中添加所有其他js
$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');