zoukankan      html  css  js  c++  java
  • easyUI datagrid 行上移 下移 置顶 置底

    //上移
    function MoveUp() {
        var row = $("#Student_Table").datagrid('getSelected');
        var index = $("#Student_Table").datagrid('getRowIndex', row);
        mysort(index, 'up', 'Student_Table');
         
    }
    //下移
    function MoveDown() {
        var row = $("#Student_Table").datagrid('getSelected');
        var index = $("#Student_Table").datagrid('getRowIndex', row);
        mysort(index, 'down', 'Student_Table');
         
    }
     
     
    function mysort(index, type, gridname) {
        if ("up" == type) {
            if (index != 0) {
                var toup = $('#' + gridname).datagrid('getData').rows[index];
                var todown = $('#' + gridname).datagrid('getData').rows[index - 1];
                $('#' + gridname).datagrid('getData').rows[index] = todown;
                $('#' + gridname).datagrid('getData').rows[index - 1] = toup;
                $('#' + gridname).datagrid('refreshRow', index);
                $('#' + gridname).datagrid('refreshRow', index - 1);
                $('#' + gridname).datagrid('selectRow', index - 1);
            }
        } else if ("down" == type) {
            var rows = $('#' + gridname).datagrid('getRows').length;
            if (index != rows - 1) {
                var todown = $('#' + gridname).datagrid('getData').rows[index];
                var toup = $('#' + gridname).datagrid('getData').rows[index + 1];
                $('#' + gridname).datagrid('getData').rows[index + 1] = todown;
                $('#' + gridname).datagrid('getData').rows[index] = toup;
                $('#' + gridname).datagrid('refreshRow', index);
                $('#' + gridname).datagrid('refreshRow', index + 1);
                $('#' + gridname).datagrid('selectRow', index + 1);
            }
        }
     
    }
    function setTopOrBottom(isTop) {
                var rows = $('#dg').datagrid('getSelections'),newRows=JSON.parse(JSON.stringify(rows));
                if (rows.length == 0) { alert('请选择要操作的数据行!'); return; }
               
                for (var i = rows.length - 1; i >= 0; i--) {
                    $('#dg').datagrid('deleteRow', $('#dg').datagrid('getRowIndex', rows[i]));
                }
                
                for (var i = newRows.length - 1; i >= 0; i--) {
                    if (isTop) $('#dg').datagrid('insertRow', { index: 0, row: newRows[i] });
                    else $('#dg').datagrid('appendRow', newRows[i]);
                }
            }
  • 相关阅读:
    蓝桥杯如何训练?(附VIP题库)
    scratch2.0的教材视频,王木头系列
    out文件 dev c++
    MongoDB 学习笔记
    golang 学习笔记 -- struct interface的使用
    goang学习笔记---struct
    golang 学习笔记 ---JSON
    golang学习笔记 ---rand
    golang学习笔记 --go test
    golang学习笔记---string && strconv
  • 原文地址:https://www.cnblogs.com/qiao20/p/13731135.html
Copyright © 2011-2022 走看看