开发者

jqGrid copy between grids

I have a page that has two jqGrids on it. One contains a list of available options, the other contains a list of included options. When the page is loaded each gr开发者_JAVA技巧id gets it's initial data from the server. After that I want the user to be able to move rows between grids until they're ready to submit the final result.

My code to accomplish this is:

function CopySelected(fromGrid, toGrid)
    {
        var grid = jQuery(fromGrid);
        var rowKey = grid.getGridParam("selrow");
        if(rowKey != null)
        {
            var row = grid.jqGrid('getRowData', rowKey);
            grid.delRowData(rowKey);
            jQuery(toGrid).addRowData(rowKey, row);
        }
    }

The problem with this approach is that I end up with duplicate rowids in the destination grid. Is there a way tell jqGrid to create a new ID, or get the next free ID?


You can just use any prefix for the ids from the destination grid:

jQuery(toGrid).addRowData("bla_"+rowKey, row);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜