yii网格不遵循页面大小

时间:2013-11-05 05:41:50

标签: php yii

我在yii中进行了这种典型的搜索。

除了网格视图不显示所有结果外,一切正常。

标题显示“显示结果1-2的6个结果”,尽管下拉列表中的页面大小设置为20。

这是我的数据提供者

public function search() {
    // Warning: Please modify the following code to remove attributes that
    // should not be searched.
    $criteria=new CDbCriteria;

    if(isset($_GET['BaseIar']['dateReceived_end']))
    {
        $this->dateReceived_end= $_GET['BaseIar']['dateReceived_end'];
        $this->dateReceived_start= $_GET['BaseIar']['dateReceived_start'];
    }
    if(isset($_GET['BaseIar']['dateInspected_end']))
    {
        $this->dateInspected_end= $_GET['BaseIar']['dateInspected_end'];
        $this->dateInspected_start= $_GET['BaseIar']['dateInspected_start'];
    }
    if(isset($_GET['BaseIar']['acquisitionDate_end']))
    {
        $this->acquisitionDate_end= $_GET['BaseIar']['acquisitionDate_end'];
        $this->acquisitionDate_start= $_GET['BaseIar']['acquisitionDate_start'];
    }
    if(isset($_GET['BaseIar']['prDate_end']))
    {
        $this->prDate_end= $_GET['BaseIar']['prDate_end'];
        $this->prDate_start= $_GET['BaseIar']['prDate_start'];
    }
    if(isset($_GET['BaseIar']['poDate_end']))
    {
        $this->poDate_end= $_GET['BaseIar']['poDate_end'];
        $this->poDate_start= $_GET['BaseIar']['poDate_start'];
    }
    if(isset($_GET['BaseIar']['invoiceDate_end']))
    {
        $this->invoiceDate_end= $_GET['BaseIar']['invoiceDate_end'];
        $this->invoiceDate_start= $_GET['BaseIar']['invoiceDate_start'];
    }
    if(isset($_GET['BaseIar']['deliveryReceiptDate_end']))
    {
        $this->deliveryReceiptDate_end= $_GET['BaseIar']['deliveryReceiptDate_end'];
        $this->deliveryReceiptDate_start= $_GET['BaseIar']['deliveryReceiptDate_start'];
    }
    if(isset($_GET['BaseIar']['psDate_end']))
    {
        $this->psDate_end= $_GET['BaseIar']['psDate_end'];
        $this->psDate_start= $_GET['BaseIar']['psDate_start'];
    }
    if(isset($_GET['BaseIar']['class_no']))
    {
        $this->classNo= $_GET['BaseIar']['class_no'];
    }

    // ------------------------- query outside iar (equip,supply)

    if(!empty($_GET['BaseIar']['itemType'])){       
        if($this->itemType=="Equipment")
        {
            error_log("1 Equipment");
                $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $criteria->condition .= "class.status_id IS NOT NULL";
        }
        else if($this->itemType=="Supply"){
            error_log("2 Supply");
                $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $criteria->condition .= "classSi.id > 0";
        }
    }

    if(!empty($_GET['BaseIar']['article'])){
        if($_GET['BaseIar']['article'] !='empty'){
            $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $this->article=$_GET['BaseIar']['article'];
            error_log("3 article".$this->article);
            $criteria->compare('article0.name', $this->article, false);
            $criteria->compare('arti.description', $this->article, false, 'OR');
        }
    }
    if(!empty($_GET['BaseIar']['description'])){
        if($_GET['BaseIar']['description'] !='empty'){
            $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $this->description=$_GET['BaseIar']['description'];
            error_log("4 description".$this->description);
            $criteria->compare('class.description', $this->description, true);
            $criteria->compare('classSi.description', $this->description, true, 'OR');
        }
    }
    if(!empty($_GET['BaseIar']['condition_id'])){
        if($_GET['BaseIar']['condition_id'] !='empty'){
            $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $this->condition_id=$_GET['BaseIar']['condition_id'];
            error_log("5 condition_id".$this->condition_id);
            $criteria->compare('class.condition_id', $this->condition_id, false ); // true is equivalence of like %%
        }
    }
    if(!empty($_GET['BaseIar']['class_no'])){
        if($_GET['BaseIar']['class_no'] !='empty'){
            $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $this->class_no=$_GET['BaseIar']['class_no'];
            error_log("6 class_no".$this->class_no);
            $criteria->compare('class.class_no', $this->classNo, false );
        }
    }
    if(!empty($_GET['BaseIar']['status_id'])){
        if($_GET['BaseIar']['status_id'] !='empty'){
            $criteria->with = array('class','classSi','class.article0','classSi.arti');
            $this->status_id=$_GET['BaseIar']['status_id'];
            error_log("7 status_id".$this->status_id);
            $criteria->compare('class.status_id', $this->status_id, false ); // true is equivalence of like %%
        }
    }


    //----------------------------------------- query for data range

    if(!empty($this->dateReceived_start) && !empty($this->dateReceived_end)){
        $criteria->condition = "t.dateReceived >= '$this->dateReceived_start' and t.dateReceived <= '$this->dateReceived_end'";
    }

    if(!empty($this->dateInspected_start) && !empty($this->dateInspected_end)){
        $criteria->condition = "t.dateInspected >= '$this->dateInspected_start' and t.dateInspected <= '$this->dateInspected_end'";
    }

    if(!empty($this->acquisitionDate_start) && !empty($this->acquisitionDate_end)){
        $criteria->condition = "t.acquisitionDate >= '$this->acquisitionDate_start' and t.acquisitionDate <= '$this->acquisitionDate_end'";
    }

    if(!empty($this->prDate_start) && !empty($this->prDate_end)){
        $criteria->condition = "t.prDate >= '$this->prDate_start' and t.prDate <= '$this->prDate_end'";
    }

    if(!empty($this->poDate_start) && !empty($this->poDate_end)){
        $criteria->condition = "t.poDate >= '$this->poDate_start' and t.poDate <= '$this->poDate_end'";
    }

    if(!empty($this->invoiceDate_start) && !empty($this->invoiceDate_end)){
        $criteria->condition = "t.invoiceDate >= '$this->invoiceDate_start' and t.invoiceDate <= '$this->invoiceDate_end'";
    }

    if(!empty($this->deliveryReceiptDate_start) && !empty($this->deliveryReceiptDate_end)){
        $criteria->condition = "t.deliveryReceiptDate >= '$this->deliveryReceiptDate_start' and t.deliveryReceiptDate <= '$this->deliveryReceiptDate_end'";
    }

    if(!empty($this->psDate_start) && !empty($this->psDate_end)){
        $criteria->condition = "t.psDate >= '$this->psDate_start' and t.psDate <= '$this->psDate_end'";
    }

    $criteria->compare('id',$this->id,true);
    if(!empty($this->receivedBy))
    $criteria->compare('receivedBy',$this->receivedBy,true);
    if(!empty($this->inspectedBy))
    $criteria->compare('inspectedBy',$this->inspectedBy,true);
    if(!empty($this->endUser))
    $criteria->compare('endUser',$this->endUser,true);
    if(!empty($this->requisitionOffice))
    $criteria->compare('requisitionOffice',$this->requisitionOffice,true);
    if(!empty($this->accountCode))
    $criteria->compare('accountCode',$this->accountCode,true);
    if(!empty($this->fundSource))
    $criteria->compare('fundSource',$this->fundSource,true);
    if(!empty($this->supplier))
    $criteria->compare('supplier',$this->supplier,true);
    if(!empty($this->prNo))
    $criteria->compare('prNo',$this->prNo,true);
    if(!empty($this->poNo))
    $criteria->compare('poNo',$this->poNo,true);
    if(!empty($this->invoiceNo))
    $criteria->compare('invoiceNo',$this->invoiceNo,true);
    if(!empty($this->deliveryRecieptNo))
    $criteria->compare('deliveryRecieptNo',$this->deliveryRecieptNo,true);
    if(!empty($this->psNo))
    $criteria->compare('psNo',$this->psNo,true);
    $criteria->order = 't.id DESC';

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
        'pagination'=>array(
            'pageSize'=>$this->pageSize,
        ),
        'sort'=>array(
            'attributes'=>array(
                '*',
            ),
        ),
    ));

我在这里缺少什么?

谢谢你们!

1 个答案:

答案 0 :(得分:0)

尝试删除排序设置(在标准中填写),结果代码为:

return new CActiveDataProvider($this, array(
    'criteria'=>$criteria,
    'pagination'=>array(
        'pageSize'=>$this->pageSize,
    ),
));