EasyUI Forum
April 16, 2024, 04:31:06 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Menubutton must click twice when open window  (Read 9020 times)
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« 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:
Code:
<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:
Code:
$('#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 + '&nbsp;&nbsp;<i class="fa fa-long-arrow-right" style="color:#6E5888"></i>&nbsp;&nbsp;<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....
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: December 09, 2016, 08:01:02 PM »

You can custom the whole drop-down menu. Please try this code.
Code:
<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" class="menu-content">
<div>
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" ondblclick="cetakABSKUL('pilih','')" style="width:200px;text-align:left">Sesuai Pilihan</a>
</div>
<div>
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" ondblclick="cetakABSKUL('semua','')" style="width:200px;text-align:left">Keseluruhan</a>
</div>
</div>
Logged
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« Reply #2 on: December 09, 2016, 08:26:33 PM »

Thanks for your response jarry... Smiley
 
I want to run my function with single click not double click...

The problem is when I click that menu item, it does not carry out my functions. I must click it again to run it...

How to fix it, so when I click my menu item can perform my functions without having to click again ....
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #3 on: December 10, 2016, 05:51:06 AM »

Please look at this example http://code.reloado.com/ayedij3/edit#preview. It works fine.
Logged
anugrast
Jr. Member
**
Posts: 52


View Profile Email
« Reply #4 on: December 10, 2016, 07:31:00 PM »

Dear jarry...

I apologize ... an error occurred in the script that I made ... now everything is going well...

Thanks for your help....   Smiley Smiley Smiley
« Last Edit: December 10, 2016, 08:48:23 PM by anugrast » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!