easy ui 单元格编辑

    xiaoxiao2021-12-10  8

    $.extend($.fn.datagrid.methods, { editCell: function(jq,param){ return jq.each(function(){ var opts = $(this).datagrid('options'); var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields')); for(var i=0; i<fields.length; i++){ var col = $(this).datagrid('getColumnOption', fields[i]); col.editor1 = col.editor; if (fields[i] != param.field){ col.editor = null; } } $(this).datagrid('beginEdit', param.index); var ed = $(this).datagrid('getEditor', param); if (ed){ if ($(ed.target).hasClass('textbox-f')){ $(ed.target).textbox('textbox').focus(); } else { $(ed.target).focus(); } $(ed.target).bind('keyup', function() { if (window.event.keyCode == 13) { $('#table_r').datagrid('endEdit', editIndex); } }); } for(var i=0; i<fields.length; i++){ var col = $(this).datagrid('getColumnOption', fields[i]); col.editor = col.editor1; } }); } }); var editIndex = undefined; function onEndEdit(index, row){ f_je(index); f_total(); return; var ed = $(this).datagrid('getEditor', { index: index, field: 'productid' }); row.productname = $(ed.target).combobox('getText'); } function endEditing(){ if (editIndex == undefined){return true} if ($('#table_r').datagrid('validateRow', editIndex)){ $('#table_r').datagrid('endEdit', editIndex); editIndex = undefined; return true; } else { return false; } } function onClickCell(index, field){ if (editIndex != index){ if (endEditing()){ $('#table_r').datagrid('selectRow', index) .datagrid('beginEdit', index); var ed = $('#table_r').datagrid('getEditor', {index:index,field:field}); if (ed){ $(ed.target).bind('keyup', function() { if (window.event.keyCode == 13) { $('#table_r').datagrid('endEdit', editIndex); } }); ($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus(); } editIndex = index; } else { setTimeout(function(){ $('#table_r').datagrid('selectRow', editIndex); },0); } } } function f_total(){ var table_r_data=$('#table_r').datagrid('getData'); var data_r=table_r_data.rows; var total=0; for (var i=0; i < data_r.length; i++) { total += data_r[i].sl* data_r[i].prpricein; } table_r_data.footer[0].je=total; $('#table_r').datagrid('reloadFooter',table_r_data.footer); }
    转载请注明原文地址: https://ju.6miu.com/read-700232.html

    最新回复(0)