zoukankan      html  css  js  c++  java
  • JqGrid把数据行插入指定位置的方法addRowData

    1、首页在colModel里写好方法,如下代码options.rowId是获取当前行的编号

    {
       label: '操作',  60, align: 'center', formatter: function (cellvalue, options, rowObject) {
       return '<span><a href="javascript:AddGridRow(' + options.rowId + ')" title="增加行">+</a>&nbsp;&nbsp;&nbsp;<a href="javascript:DelGridRow(' + options.rowId + ')"" title="删除行">-</a></span>'; 
       }
    },

    2、增加到指定位置的方法如下:

    AddGridRow = function (rowId) {
        var $grid = $("#gridTable");
        //在行号序列中获取最大的编号
        var maxRowId = Math.max.apply(Math, $grid.jqGrid('getDataIDs'))
        window.setTimeout(function () {
            $grid.jqGrid("addRowData", maxRowId + 1, rowdata, "before", rowId);
        }, 200);
    
        //RefreshTotal();
    }

    注:“addRowData”是根据参数插入一行新的数据,rowid为新行的id,data为新行的数据,position为新增行的位置,srcrowid为新增行的参考位置。position可以为[first,last,before,after],如果是before或者after时需要指定相对的行ID编号

  • 相关阅读:
    SQL Server连接Oracle详细步骤
    SQLServer2012连接mysql5.5
    SQL Server的链接服务器技术
    2键盘录入Scanner
    1标识符
    电脑从新分盘(软件)
    Tomcat安装配置
    windows下安装和配置多个版本的JDK
    Myeclipse2014的安装
    Could not find acceptable representation
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/8806839.html
Copyright © 2011-2022 走看看