anugrast
|
|
« on: December 09, 2016, 07:36:07 PM » |
|
Dear All.. I've made datagrid with menubutton on it's toolbar to print pdf on new window. I always must click twice before open that new window with window.open This is my script... HTML: <table id="dgCTKKUL" style="width:930px;min-height:100%"></table> <div id="tbCTKKUL" style="height:27px;" class="hidenshow"> <div style="float:left;margin:1px;"> <input id="cariCTKKUL" class="easyui-searchbox" data-options="prompt:'Cari Kode/Nama Mata Kuliah',searcher:searchCTKKUL" style="width:300px;"></input> </div> <div style="float:right;margin:1px"> <a href="#" class="easyui-menubutton c1" iconCls="fa fa-print" plain="false" data-options="menu:'#mmCTKABSKUL'" style="height:25px;"><B>Cetak Absen</B></a> <div id="mmCTKABSKUL" style=""> <div data-options="iconCls:'icon-ok-2'" onClick="cetakABSKUL('pilih','')">Sesuai Pilihan</div> <div data-options="iconCls:'icon-list-m1-list'" onClick="cetakABSKUL('semua','')">Keseluruhan</div> </div> <a href="#" class="easyui-menubutton c2" iconCls="fa fa-print" plain="false" data-options="menu:'#mmCTKABKKUL'" style="height:25px;"><B>Cetak Absen Kosong</B></a> <div id="mmCTKABKKUL" style=""> <div data-options="iconCls:'icon-ok-2'" onClick="cetakABSKUL('pilih','ksg')">Sesuai Pilihan</div> <div data-options="iconCls:'icon-list-m1-list'" onClick="cetakABSKUL('semua','ksg')">Keseluruhan</div> </div> </div> </div>
JS: $('#dgCTKKUL').datagrid({ rownumbers:true,toolbar:'#tbCTKKUL',pagination:true,pageSize:25,pageList: [25,50,100,200,300], url:'_modul/mod_ctkkuliah/aksi_ctkkuliah.php?act=listJADKUL',remoteSort:true, sortName:'hari',striped:true, view:groupview, groupField:'kodenama', groupFormatter:function(value,rows){ return value + ' <i class="fa fa-long-arrow-right" style="color:#6E5888"></i> <i style="color:#367FA6">' + rows.length + ' kelas</i>'; }, columns:[[ {field:'ck',checkbox:true}, {field:'hari',width:70,align:'center',sortable:true,formatter:formatNamaHari,title:'Hari'}, {field:'jamkuliah',width:90,align:'center',sortable:false,title:'Jam'}, {field:'kodemk',width:100,align:'center',sortable:true,title:'Kode MK'}, {field:'namamk',width:200,align:'left',sortable:true,title:'Nama MK'}, {field:'nama_kelas',width:60,align:'center',sortable:false,formatter:namakelas, title:'Kelas'}, {field:'namadosen',width:200,align:'left',sortable:true,title:'Dosen Pengasuh'}, {field:'ruang',width:70,align:'center',sortable:false,title:'Ruang'}, {field:'jmlpeserta',width:70,align:'center',sortable:false,title:'Peserta'} ]], singleSelect:true, ctrlSelect:true, checkOnSelect:false, selectOnCheck:false, idField:'kodemkelas' });
function cetakABSKUL(pilihCTK,kosong){ timestamp = new Date().getTime(); if(pilihCTK=='pilih') { rowsCHECKED = $("#dgCTKKUL").datagrid("getChecked"); countCHECKED = rowsCHECKED.length; if(countCHECKED>0) { jsonObj = []; for (i = 0; i < countCHECKED; i++) { item = {}; item ["kmk"] = rowsCHECKED[i].kodemk; item ["kls"] = rowsCHECKED[i].kelas; jsonObj.push(item); } jsonStr = JSON.stringify(jsonObj); $.post('_modul/mod_ctkkuliah/aksi_ctkkuliah.php?act=cetakABSENKULIAH&ts='+timestamp,{datanya:jsonStr,id:1,absong:kosong},function(result){ if (result.success){ window.open('_assets/_topdf/new_topdf1.php?ts='+timestamp+'&/i1/='+result.encPDF1+'&/i2/='+result.encPDF2+'&/i3/='+result.savepdf,'_blank','width=800,height=500,resizable=yes,location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=600,top=0'); $("#dgCTKKUL").datagrid("clearChecked"); } else { messager_alert(toTitleCase(result.show), result.message, result.show); } },'json'); } else { var row = $('#dgCTKKUL').datagrid('getSelected'); if (row){ if(row.jmlpeserta>0) { $.post('_modul/mod_ctkkuliah/aksi_ctkkuliah.php?act=cetakABSENKULIAH&ts='+timestamp,{kmk:row.kodemk,kls:row.kelas,id:2,absong:kosong},function(result){ if (result.success){ window.open('_assets/_topdf/new_topdf1.php?ts='+timestamp+'&/i1/='+result.encPDF1+'&/i2/='+result.encPDF2+'&/i3/='+result.savepdf,'_blank','width=800,height=500,resizable=yes,location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=600,top=0') } else { messager_alert(toTitleCase(result.show), result.message, result.show); } },'json'); } else { messager_alert('Error','Tidak ada yang bisa dicetak!','error'); } } else { messager_alert('Error','Anda belum memilih data!','error'); } } } else { $.post('_modul/mod_ctkkuliah/aksi_ctkkuliah.php?act=cetakABSENKULIAH&ts='+timestamp,{id:3,absong:kosong},function(result){ if (result.success){ window.open('_assets/_topdf/new_topdf1.php?ts='+timestamp+'&/i1/='+result.encPDF1+'&/i2/='+result.encPDF2+'&/i3/='+result.savepdf,'_blank','width=800,height=500,resizable=yes,location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=600,top=0') } else { messager_alert(toTitleCase(result.show), result.message, result.show); } },'json'); } }
function namakelas(val,row){ if (row.nonkrs>0){ return '<span>X</span>'; } else { return '<span>'+val+'</span>'; } }
The problem only when I click menubutton to run my function (cetakABSKUL), I must click twice... I don't know how to fix it... Can anyone help me? Sorry if my english is not well....
|