Yii Framework Forum: [SOLVED]cara ngambil dataProvider dr cgridview - Yii Framework Forum

Jump to content

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

[SOLVED]cara ngambil dataProvider dr cgridview export to excel Rate Topic: -----

#1 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 08 June 2012 - 05:43 AM

haloha para mastaa yii,,

saya mw nanya gmn cara ngambil dataProvider dari cgridview ?

saya lagi pake ext.EExcelView dmn data nyah diambil dr cgridview,, ini ga jadi masalah waktu saya pake model tapi karena kebutuhan, cgridview saya pake dataProvider yang ngambil datanya pake sql,, kurang lebih gini scripnyahh
$sql=" ( SELECT ... ... ... leftjoin ... ... ... )";
	
	
	$dataProvider=new CSqlDataProvider ($sql, array(
	'totalItemCount'=>$count,
	
			'db'=>Yii::app()->db,
			'pagination'=>array(
				'pageSize'=>30,
			),
		));
		
		$this->widget('zii.widgets.grid.CGridView', array(
				'id'=>'pie-grid',
				'dataProvider'=>$dataProvider,//->getData(),
				'columns'=>array(
                                             'id',
                                             'nama',
                                 )));




nah ane kan kasi button buat export excel nyah..


echo CHtml::Button('Excel', array('submit' => Yii::app()->createUrl('report/ToCSVl',array('id'=>'pie-grid'))));



nah ane kaga tw mesti nulis apah dii controller nyah buat dptin dataProvidernyah,, kirain kasi id-grid ajah udh cukup,, hehehehehhh

monggo para mastaa dan tmn yiier's sekalian yang mw ngasi saran atw masukkann,, segala bantuan nyah sangat diharapkan :D
terimakasiii sebelumnyah,,
0

#2 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 14 June 2012 - 10:15 AM

can anyone share information pleaseeee . . . . . .

seperti sudah tersesat rasanya,,
:(
0

#3 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 14 June 2012 - 08:35 PM

ini tuh cuma mau di export ke csv gan?.

$sql=" ( SELECT ... ... ... leftjoin ... ... ... )";
        $dataProvider=new CSqlDataProvider ($sql, array(
        'totalItemCount'=>$count,
        
                        'db'=>Yii::app()->db,
                        'pagination'=>array(
                                'pageSize'=>30,
                        ),
                ));

$getDataProvidernya = $dataProvider->data;
var_dump($getDataProvidernya) // klo di var_dump gini keluar gak gan?

klo keluar , langsung aja export pake phpexcel , sok taunya saya aja ini mah gan :D
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#4 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 15 June 2012 - 03:13 AM

keluar data nyah, tp ane kaga ngerti pake phpexcel,

ane udh nyoba tambahin
//header("Content-type: application/octet-stream");
//header("Content-Disposition: attachment; filename=Report.xls");
//header("Pragma: no-cache");
//header("Expires: 0");

tp data yang diexport kosong, udh nyoba diubah.ubah malah yang keexport menu bukan dataProvidernyah,,
mungkin ada yang salah atau yang kurang mohon dikasii tau, makasiii
0

#5 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 15 June 2012 - 04:02 AM

View Postsaya pemula, on 15 June 2012 - 03:13 AM, said:

keluar data nyah, tp ane kaga ngerti pake phpexcel,

ane udh nyoba tambahin
//header("Content-type: application/octet-stream");
//header("Content-Disposition: attachment; filename=Report.xls");
//header("Pragma: no-cache");
//header("Expires: 0");

tp data yang diexport kosong, udh nyoba diubah.ubah malah yang keexport menu bukan dataProvidernyah,,
mungkin ada yang salah atau yang kurang mohon dikasii tau, makasiii



mungkin kyk gini gan
$sql=" ( SELECT ... ... ... leftjoin ... ... ... )";
        $dataProvider=new CSqlDataProvider ($sql, array(
        'totalItemCount'=>$count,
        
                        'db'=>Yii::app()->db,
                        'pagination'=>array(
                                'pageSize'=>30,
                        ),
                ));

$dataProvider->pagination= false; // for retrive all modules
$data = $dataProvider->data;
foreach ($data as $rownya)
{
$untukrowexcel[]= $rownya;
}
// ane pake phpexcel
Yii::import('application.extensions.phpexcel.JPhpExcel');
$xls = new JPhpExcel('UTF-8', false, 'laporansaya-worksheet');	
$xls->addArray($untukrowexcel);	
$xls->generateXML('fileLaporan '.date('Y-m-d'));


sekali lagi ma'af , ini mah sok taunya saya aja. maklum newbie :D
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#6 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 15 June 2012 - 06:22 AM

thx bgt ini mw dicoba dulu,, wah Standard Member merendaahhh,,

$sql=" ( SELECT ... ... ... leftjoin ... ... ... )";
        $dataProvider=new CSqlDataProvider ($sql, array(
        'totalItemCount'=>$count,
        
                        'db'=>Yii::app()->db,
                        'pagination'=>false,

//$dataProvider->pagination= false; // for retrive all modules


gini bisa kn buat disable paginationnyah,,

nti klo masi belum bisa nanya lagi yh massttaaaa chadnox :) ....
0

#7 User is offline   ahmadroni 

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

Posted 15 June 2012 - 08:46 PM

gimana dah berhasil belum??
Hospital Cost Management System and
Hospital Management Information System
0

#8 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 18 June 2012 - 12:06 AM

belum gan,, hasilnyah keluar tp masii ada error nyahh,, link menu saya masiihh tetep ke export juga(saya atch gambarnyah),, gmn yh caranyah biar cuma data cgridview nyah ajah ?

smoga ada saran dan masukkan,, thx :(
0

#9 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 18 June 2012 - 11:37 PM

maklum yh anak baruuu hehehehehhh,,
ternyata cuma perlu ngerubah render jadii renderPartial hehehehehhh,,
makasii para mastaa dan suhu sekaliaann,,
this topic SOLVED :)
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