Donavan Stanley
Donavan Stanley

Reputation: 107

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 grid 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?

Upvotes: 2

Views: 3112

Answers (1)

Oleg
Oleg

Reputation: 221997

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

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

Upvotes: 1

Related Questions