Yii Framework Forum: Bagaimana membuat total dI footer CGRIDVIEW - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bagaimana membuat total dI footer CGRIDVIEW Bagaimana membuat total di footer CGRIDVIEW Rate Topic: -----

#1 User is offline   faraz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-May 12

Posted 27 June 2012 - 09:48 PM

Bagaimana membuat footer yang isinya total dari kolom-kolom di atasnya di cgridview?
0

#2 User is offline   faraz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-May 12

Posted 27 June 2012 - 10:51 PM

Ternyata cukup simple dulur...
tinggal tambahin di model nya
public function getSearchCriteria(){

$criteria=new CDbCriteria;

$criteria->compare('id',$this->id);
$criteria->compare('nama',$this->nama,true);
$criteria->compare('nilai',$this->nilai,true);
return $criteria;
}

public function getTotals()
{
$criteria=$this->getSearchCriteria();
$criteria->select='SUM(nilai)';
return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
}
di view:
'footer'=>'Total: '.number_format($model->getTotals()),
1

#3 User is offline   infoxbos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 08-June 12

Posted 28 June 2012 - 10:49 PM

View Postfaraz, on 27 June 2012 - 10:51 PM, said:

Ternyata cukup simple dulur...
tinggal tambahin di model nya
public function getSearchCriteria(){

$criteria=new CDbCriteria;

$criteria->compare('id',$this->id);
$criteria->compare('nama',$this->nama,true);
$criteria->compare('nilai',$this->nilai,true);
return $criteria;
}

public function getTotals()
{
$criteria=$this->getSearchCriteria();
$criteria->select='SUM(nilai)';
return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
}
di view:
'footer'=>'Total: '.number_format($model->getTotals()),


Terimakasih mas bos atas ilmunya. Sukses ane bisa totalin kolom nya.
Trimakasih master :D
0

#4 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 04 August 2012 - 07:54 PM

mungkin disini dapat jadi tambahan referensi..
http://www.yiiframew...coming-from-db/
Hospital Cost Management System and
Hospital Management Information System
0

#5 User is offline   mbahsomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 29-March 10

Posted 10 August 2012 - 12:25 AM

Wah keren, perlu di coba tuh
Sugik Puja Kusuma [mbahsomo]
http://sugik.do-event.com
0

#6 User is offline   Melz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-October 13

Posted 10 October 2013 - 04:34 AM

View Postfaraz, on 27 June 2012 - 10:51 PM, said:

Ternyata cukup simple dulur...
tinggal tambahin di model nya
public function getSearchCriteria(){

$criteria=new CDbCriteria;

$criteria->compare('id',$this->id);
$criteria->compare('nama',$this->nama,true);
$criteria->compare('nilai',$this->nilai,true);
return $criteria;
}

public function getTotals()
{
$criteria=$this->getSearchCriteria();
$criteria->select='SUM(nilai)';
return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
}
di view:
'footer'=>'Total: '.number_format($model->getTotals()),


di viewnya untuk 'footer'=>'Total: '.number_format($model->getTotals()), diletakkan disebelah mananya yaa...
mohon pencerahannya..terima kasih
0

#7 User is offline   Wisanggeni 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 17-June 14

Posted 17 June 2014 - 09:11 AM

Sekedar menambahkan sedikit barangkali bisa berguna buat temen2 yg lain..

untuk models nya :

public function getTotalB(){

$totB = Yii::app()->db->createCommand()
->select('sum(total_pembayaran) as mySum')
->from('bpjs')
->where('id_jenis_pembayaran =2')
->queryScalar();
return "Total Bpjs : Rp.".$totB;
}

kemudian untuk view nya :

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'laporan-bpjs-grid',
'dataProvider'=>$model->search(),
'columns'=>array(

...........................................

array(
'name'=>'relrincian.total_pembayaran',
'footer'=>$model->getTotalB(),
),

............................................
),
));

Itu hanya contoh simple barangkali berguna untuk temen2..
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users