2013-07-19 94 views
0

我是新Yii中我要顯示在頂部CGridView Yii中新插入的項,但不知道它是如何可能的新條目?cgridview顯示在頂部警予

public function search() 
    { 
     $criteria=new CDbCriteria; 
     $criteria->alias = "jb"; 
     $criteria->compare('title', $this->title, true); 
     $criteria->compare('notes', $this->notes, true); 
     $criteria->compare('createdon', $this->createdon, true); 
     $criteria->compare('expirydate', $this->expirydate, true); 
     $criteria->join= 'INNER JOIN company co ON (co.companyid=jb.companyid)'; 
     return new CActiveDataProvider(get_class($this), array(
       'criteria' => $criteria, 
     )); 
+0

任何機構幫助PLZ? – user2598211

+0

你嘗試在cgridview中排序數據? – Ninad

回答

0

爲什麼不使用關係進行連接?

$criteria=new CDbCriteria; 
    $criteria->alias = "jb"; 
    $criteria->compare('title', $this->title, true); 
    $criteria->compare('notes', $this->notes, true); 
    $criteria->compare('createdon', $this->createdon, true); 
    $criteria->compare('expirydate', $this->expirydate, true); 
    $criteria->with('company'); 
    $criteria->together=>true; 

    return new CActiveDataProvider(get_class($this), array(
      'criteria' => $criteria, 
    )); 

,然後defaultScope爲JB模型

public function defaultScope() 
{ 
    $alias = $this->getTableAlias(false,false); 
    return array(
     'order'=>"`$alias`.`id` DESC", 
    ); 
}