]Yii2]tips menggunakan expand row column dari kartik

Mei 15, 2018

langsung aja nih sanak, cara yang saya pakai adalah menggunakan ajax untuk menampilkan data saat klik, sesuai doc nya kartik, kita gunakan detailUrl dan request postnya expandRowKey atau expandRowInd, tipsnya jika sumber dataprovider pada gridview tag data-key saat event click 0 atau tepatnya expandRowKey adalah 0 atau nilai index berurut, kita bisa lakukan costum dengan merubah key dari dataProvider,
misal


$query = "concat(kode_skpd,'|',kode_provinsi) as id,nama_provinsi"

..

..

..

$dataProvider = new \yii\data\ActiveDataProvider([
'key'=>'id',
'query'=>$query
]);

naa dengan begitu saat event click expand , dan di controller request post expandRowKey bisa di explode sesuai kondisi , OK semoga paham yaa

Iklan

[TIPS] Menambahkan Export Excel dan PDF di widget Datatables Yii2

Februari 24, 2018

sama seperti tips sebelumnya saya masih pakai https://github.com/fedemotta/yii2-widget-datatables sebagain extension pengganti grdiview Yii2 selain kartik, OK langsung aja,sesuai readme nya di untuk export bisa tambahkan


<span class="pl-s1"><span class="pl-s"><span class="pl-pds">"</span>tableTools<span class="pl-pds">"</span></span><span class="pl-k">=></span>[</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>aButtons<span class="pl-pds">"</span></span><span class="pl-k">=></span> [ </span> <span class="pl-s1"> [</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sExtends<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">"</span>copy<span class="pl-pds">"</span></span>,</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sButtonText<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-c1">Yii</span><span class="pl-k">::</span>t(<span class="pl-s"><span class="pl-pds">'</span>app<span class="pl-pds">'</span></span>,<span class="pl-s"><span class="pl-pds">"</span>Copy to clipboard<span class="pl-pds">"</span></span>)</span> <span class="pl-s1"> ],[</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sExtends<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">"</span>csv<span class="pl-pds">"</span></span>,</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sButtonText<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-c1">Yii</span><span class="pl-k">::</span>t(<span class="pl-s"><span class="pl-pds">'</span>app<span class="pl-pds">'</span></span>,<span class="pl-s"><span class="pl-pds">"</span>Save to CSV<span class="pl-pds">"</span></span>)</span> <span class="pl-s1"> ],[</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sExtends<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">"</span>xls<span class="pl-pds">"</span></span>,</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>oSelectorOpts<span class="pl-pds">"</span></span><span class="pl-k">=></span> [<span class="pl-s"><span class="pl-pds">"</span>page<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">'</span>current<span class="pl-pds">'</span></span>]</span> <span class="pl-s1"> ],[</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sExtends<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">"</span>pdf<span class="pl-pds">"</span></span>,</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sButtonText<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-c1">Yii</span><span class="pl-k">::</span>t(<span class="pl-s"><span class="pl-pds">'</span>app<span class="pl-pds">'</span></span>,<span class="pl-s"><span class="pl-pds">"</span>Save to PDF<span class="pl-pds">"</span></span>)</span> <span class="pl-s1"> ],[</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sExtends<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">"</span>print<span class="pl-pds">"</span></span>,</span> <span class="pl-s1"> <span class="pl-s"><span class="pl-pds">"</span>sButtonText<span class="pl-pds">"</span></span><span class="pl-k">=></span> <span class="pl-c1">Yii</span><span class="pl-k">::</span>t(<span class="pl-s"><span class="pl-pds">'</span>app<span class="pl-pds">'</span></span>,<span class="pl-s"><span class="pl-pds">"</span>Print<span class="pl-pds">"</span></span>)</span> <span class="pl-s1"> ],</span> <span class="pl-s1"> ]</span> <span class="pl-s1"> ]
</span>

eh nyatanya itu not work, krn dia pakai flash, akhirnya saya modify sedikit (ngapus sedikit) dari sintax sebelumnya, awalnya

saya komen di bagian tableTools jadi

selanjutnya kita tambahakan js dan css di file appasset.php ,
button export dari datatable https://datatables.net/extensions/buttons/examples/initialisation/export.html

public $css = [
'css/site.css',
' https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css',
'https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css',
];
public $js = [
'js/FileSaver.js',
' https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js',
'https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js',
'https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js',
'https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js',
'https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js',
];

terus di confignya widget datatable

Ok sudah tampilnya jd gini deh

 


Tips – Trik Desain Laporan di PHP

Juni 28, 2017

Sesuai judul deh, saya ada kasus nih desain laporan di PHP, pake HTML enaknya yaa kan kebetulan saya pake Mpdf, yang ribet dari php ini adalah bikin laporan (menurut saya sih) karena harus berkutat di tag tr,td, collspan,rowspan kadang saya males , saya sempat mikir ada ga yang drag drop HTML kaya DW, lamaaaa sudah berkutat tr td buat bikin repot akhirnya saya punya alternatif biar mempercepat kerjaan tanpa mikir sususan tag table dan kawan kawannya apalgi pake Css biar pas sesuai permintaan klient, contoh kaya digambar ini

berikut caranya Baca entri selengkapnya »


[Yii2]Membuat CRUD Modal sederhana Ke 2

Mei 2, 2017

gitu kali yaa judulnya he, pengennya sih pengen buat form modal bootstrap sederhana asal asal jadi hehe, OK simak tutorial sederhana ini

pertama, pastinya bikin table dulu misal saya bikin tabel provinsi (id INT,kode_prov CHAR,nama_prov CHAR) , terus bikin Crud pake Gii

kedua, modify file index.php di view provinsi anda, tambahkan koding ini dibawah gridview

Baca entri selengkapnya »


[Yii2] Tips pasang extension offline

April 30, 2017

begini ceritanya cerita dulu yaa, saya waktu ikut tes kerja, diperbolehkan pake framework salah satunya untuk integrasi RestApi, kebetulan di Yii ada extension keren HttpClient dan saya suka itu sering banget pake, naa internet lemot banget saat itu (*mungkin kouta limit) akhirnya saya coba lakukan seperti ini

pertama, saya buka web sebelumnya yg udah terinstal httpclient dalam vendor\yiisoft , saya copy folder httpclient nya

kedua, paste di project web yg baru di vendor\yiisoft

ketiga, di folder yiisoft diproject sebelumnya buka file extension.php cari yii-httpclient


'yiisoft/yii2-httpclient' =>
array (
'name' => 'yiisoft/yii2-httpclient',
'version' => '2.0.3.0',
'alias' =>
array (
'@yii/httpclient' => $vendorDir . '/yiisoft/yii2-httpclient',
),
),

copy scriptnya

keempat, di project web baru folder yiisoft dengan file yg sama,paste script yang sama, ok udah selesai, selamat anda berhasil instal extension offline dr project sebelumnya yg sudah terinstal