Title: Using key up, key down and enter key on edatagrid
Post by: anugrast on October 28, 2016, 08:55:00 PM
Dear All... I've create edatagrid like this and it work perfect... $('#dgNILMKDOSnilai').edatagrid({ updateUrl: '_modul/mod_nilmkdos/aksi_nilmkdos.php?act=updateNILMKDOS&pabs='+proABS+'&ptgs='+proTGS+'&puts='+proUTS+'&puas='+proUAS }); $('#dgNILMKDOSnilai').edatagrid({ fit:true,rownumbers:true,rownumberWidth:40,singleSelect:true,striped:true,emptyMsg:'Tidak Ada Data', url:'_modul/mod_nilmkdos/aksi_nilmkdos.php?act=listNILMKDOS',idField:'khsid',remoteSort:false, queryParams:{param:opts.param,cetak:sudahcetak}, columns:[[ {field:'nim',title:'NIM/No. Pokok',width:130, align:'center',rowspan:2}, {field:'nama',title:'Nama Peserta',width:300,rowspan:2}, {title:'Hadir'},{title:'Tugas'},{title:'UTS'},{title:'UAS'},{title:'Nilai',align:'center',colspan:2} ],[ {id:'idhadir',field:'hadir',width:70,title:proABS+'%',align:'center',styler:cellStylerBack}, {id:'idtugas',field:'tugas',width:70,title:proTGS+'%',align:'center',styler:cellStylerBack}, {id:'iduts',field:'uts',width:70,title:proUTS+'%',align:'center',styler:cellStylerBack}, {id:'iduas',field:'uas',width:70,title:proUAS+'%',align:'center',styler:cellStylerBack}, {field:'nil_angka',title:'Angka',width:70,align:'center',styler:cellStylerBold}, {field:'nil_huruf',title:'Huruf',width:70,align:'center',styler:cellStylerBold} ]], onBeforeEdit: function(index,row){ var colHDR = $(this).edatagrid('getColumnOption', 'hadir'); var colTGS = $(this).edatagrid('getColumnOption', 'tugas'); var colUTS = $(this).edatagrid('getColumnOption', 'uts'); var colUAS = $(this).edatagrid('getColumnOption', 'uas'); // if(parseInt(sudahcetak)==0) { colHDR.editor = { type:'numberbox',options:{required:true,min:0,missingMessage:'Wajib di-isi',validType:'isiHADIR[75,100]'} }; colTGS.editor = colUTS.editor = colUAS.editor = { type:'numberbox',options:{required:true,min:0,missingMessage:'Wajib di-isi',validType:'isi[0,100]'} }; } else { colHDR.editor = colTGS.editor = colUTS.editor = colUAS.editor = null; } // }, onRowContextMenu: function(e, rowIndex, rowData){ e.preventDefault(); $(this).datagrid('unselectAll'); $(this).datagrid('selectRow', rowIndex); if (!$('#tmenuNILMKdos').length){ var tmenuNILMKdos = $('<div id="tmenuNILMKdos" style="width:120px;"></div>').appendTo('body'); $('<div id="tmenuNILMKdos_cancel" iconCls="icon-undo-2" />').html('Cancel').appendTo(tmenuNILMKdos); tmenuNILMKdos.menu({ onClick: function(item){ if(item.id=="tmenuNILMKdos_cancel") { $('#dgNILMKDOSnilai').edatagrid('cancelRow'); } else { } } }); } $('#tmenuNILMKdos').menu('show', { left: e.pageX, top: e.pageY }); } });
Can we add keyboard function like key up/down and enter key on edatagrid to automatically save current row and beginEdit next row? Please help Thx
Title: Re: Using key up, key down and enter key on edatagrid
Post by: stworthy on October 29, 2016, 04:57:44 PM
Please refer to the code below: onBeginEdit: function(index,row){ var dg = $(this); var editors = dg.edatagrid('getEditors',index); for(var i=0; i<editors.length; i++){ $(editors[i].target).numberbox('textbox').bind('keydown',function(e){ if (e.keyCode == 13){ dg.edatagrid('endEdit', index); if (index<dg.edatagrid('getRows').length-1){ dg.edatagrid('selectRow', index+1).edatagrid('beginEdit', index+1); } } }) } if (editors.length){ $(editors[0].target).numberbox('textbox').focus(); } }
Title: Re: Using key up, key down and enter key on edatagrid
Post by: anugrast on October 29, 2016, 06:19:22 PM
Thanks stworthy... It work nice...
|