过滤器无法在Yii CGridView中工作(Yii 1.x)

时间:2017-03-29 20:43:17

标签: php yii cgridview

我检查了1000次我的代码 万事如意!但在我改变主题后!它不发送过滤网格视图的ajax请求 当我检查这个代码我认为是okey,我应该说我搜索并检查维基yii但我找不到我的问题

我的观点代码:

 <?php $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'product-grid',
        'itemsCssClass' => 'table table-bordered table-striped dataTable',
        'dataProvider' => $model->notDeleted()->search(),
        'filter' => $model,
        'columns' => array(
            'appId',
            array(
                'name' => 'categoryId',
                'value' => '$data->category->name',
                'filter' => CHtml::activeDropDownList($model, 'categoryId', CHtml::listData(Category::model()->notDeleted()->findAll(), 'id', 'name'),
                    array('empty' => '')

                )
            ),
            'name',
            'packageName',
            'price',
            'discount',
            'version',
            array(
                'name' => 'isActive',
                'value' => '$data->isActive ? Yii::t("app", "Yes") : Yii::t("app", "No")',
                'filter' => CHtml::activeDropDownList($model, 'isActive', array(
                    1 => Yii::t('app', 'Yes'),
                    0 => Yii::t('app', 'No'),
                ))
            ),
            array(
                'name' => 'inAppPurchase',
                'value' => '$data->inAppPurchase ? Yii::t("app", "Yes") : Yii::t("app", "No")',
                'filter' => CHtml::activeDropDownList($model, 'inAppPurchase', array(
                    1 => Yii::t('app', 'Yes'),
                    0 => Yii::t('app', 'No'),
                ))
            ),
            /*
            'createUserId',
            'createTime',
            'isDeleted',
            */
            array(
                'class' => 'CButtonColumn',
            ),
        ),
    )); ?>

和我的控制员:

 $model = new Product('search');
    $model->unsetAttributes(); // clear any default values
    if (isset($_GET['Product']))
        $model->attributes = $_GET['Product'];

    $this->render('admin', array(
        'model' => $model,
    ));

请帮助我!

1 个答案:

答案 0 :(得分:-1)

对于下一个,我有同样的问题。我像这样继续进行,并成功了。就我而言,我删除

<script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery-1.11.1.min.js">
</script>

检查页面中是否多次包含jquery.js。我遇到了同样的错误,原因是yii已经添加了jquery.js脚本,因此无需自己添加它。

Andrey Zausaylov博士 https://stackoverflow.com/a/41304449/3032180