• js表格行上下移动


    <script type="text/javascript">
    function tagPosition() {
    $('#easyTables').tabs('select', '输出方式');
    var rows = $('#dgTag').datagrid('getRows');//获取当前页的数据行
    //var ary = new Array();
    var ary = "";
    for (var i = 0; i < rows.length; i++) {
    ary += rows[i]['id']+",";
    }
    ary=ary.substring(0,ary.length-1);

    $.ajax({
    url:'../../modelFilter/Position',
    type:'POST',
    data:{"ary" : ary},
    success: function(result){
    console.log(ary);
    }
    });
    }

    //上移动
    function datagridRowMove( isUp) {
    var rows=$('#dgTag').datagrid('getRows');
    var rowlength=rows.length;
    var selectrow=$('#dgTag').datagrid('getSelected');
    var rowIndex=$('#dgTag').datagrid('getRowIndex', selectrow);
    if(rowIndex==0){
    $.messager.alert('提示', '顶行无法上移!', 'warning');
    }else{
    $('#dgTag').datagrid('deleteRow', rowIndex);//删除一行
    rowIndex--;
    $('#dgTag').datagrid('insertRow', {
    index:rowIndex,
    row:selectrow
    });
    $('#dgTag').datagrid('selectRow', rowIndex);
    }
    }
    //下移动
    function datagridRowMove1( isUp) {
    var rows=$('#dgTag').datagrid('getRows');
    var rowlength=rows.length;
    var selectrow=$('#dgTag').datagrid('getSelected');
    var rowIndex=$('#dgTag').datagrid('getRowIndex', selectrow);

    $('#dgTag').datagrid('deleteRow', rowIndex);//删除一行
    rowIndex++;
    $('#dgTag').datagrid('insertRow', {
    index:rowIndex,
    row:selectrow
    });
    $('#dgTag').datagrid('selectRow', rowIndex);
    if(rowIndex>=rowlength){
    $.messager.alert('提示', '最后一行无法下移!', 'warning');
    }
    }
    </script>
    添加onclick="tagPosition()"

    后台保存移动后数据
    @RequestMapping(value = "/Position", method = RequestMethod.POST)
    @ResponseBody
    public void position(String ary){
    if (ary !=null && !ary.equals("")) {
    ModelTag model = new ModelTag();
    String[] arr = ary.split(",");
    try {
    for (int i = 0; i < arr.length; i++) {
    model.setId(Integer.parseInt(arr[i]));
    model.setTagPosition(i + 1);
    modelFilterManager.updataTagEncryption(model);
    }
    /*model.setId(9600);
    model.setModuleId("2017021316419558");
    model.setTagPosition(1);
    modelFilterManager.updataTagEncryption(model);*/
    System.out.println("controller " + ary);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
     
  • 相关阅读:
    EasyNVR播放HLS协议时ts文件报错404是什么问题?
    【操作步骤】EasyNVR硬件设备如何设置通电不自动启动?
    C#实现QQ接口软件QQ的HTTP接口协议探究
    第一篇随笔
    Extjs继承相关
    Montgomery乘法介绍
    中国商用密码杂凑算法标准SM3算法(数字签名)
    c语言链接动态库dll
    环、商环、整数环
    大数据挖掘技术及应用(复习重点)
  • 原文地址:https://www.cnblogs.com/koubazhuanshu/p/7039535.html
Copyright © 2020-2023  润新知