//上移 function upBtn() { var selected = $(‘#caseTable‘).datagrid(‘getSelected‘); var index = $(‘#caseTable‘).datagrid(‘getRowIndex‘,selected); if(index==0){ $.messager.alert(‘系统提示‘, ‘顶行无法上移!‘, ‘warning‘); } else { var rows = $(‘#caseTable‘).datagrid(‘getRows‘); var row = rows[index]; $(‘#caseTable‘).datagrid(‘deleteRow‘, index);//删除一行 index--; $(‘#caseTable‘).datagrid(‘insertRow‘, { index:index, row:row }); var loadRows = $(‘#caseTable‘).datagrid(‘getRows‘); loadRows[index].ROWNUM_ = index + 1; loadRows[index + 1].ROWNUM_ = index + 2; $(‘#caseTable‘).datagrid(‘loadData‘,loadRows); } } //下移 function downBtn() { var selected = $(‘#caseTable‘).datagrid(‘getSelected‘); var index = $(‘#caseTable‘).datagrid(‘getRowIndex‘,selected); var rows = $(‘#caseTable‘).datagrid(‘getRows‘); var rowlength=rows.length if(index==rowlength-1){ $.messager.alert(‘系统提示‘, ‘底行无法下移!‘, ‘warning‘); }else{ var row = rows[index]; $(‘#caseTable‘).datagrid(‘deleteRow‘, index);//删除当前行 index++; $(‘#caseTable‘).datagrid(‘insertRow‘, { index:index, row:row }); var loadRows = $(‘#caseTable‘).datagrid(‘getRows‘); loadRows[index].ROWNUM_ = index + 1; loadRows[index - 1].ROWNUM_ = index; $(‘#caseTable‘).datagrid(‘loadData‘,loadRows); } }
原文地址:https://www.cnblogs.com/lonske/p/12132998.html
时间: 2024-11-06 18:45:06