Use "moveRowTo" to move selected items to another page

How would one do this? I have a column of checkboxes in a grid on one page, and what I want to do is let the user check off whatever boxes they want and then if they click print, open a pop-up window with a new grid holding only the rows selected by the user.

I’ve tried the following (my button click, call the function that holds this code):

if (cInd == 19) {
    PrintOrEmail = grid.findCell(1, cInd, false);
    //alert(PrintOrEmail);

    if (PrintOrEmail.length !== 0 && ChkButton('btn_PrintSubmittals') == true) {
        // Reset button click check
        intCheckButtonHitOnce = 0;

        // Refresh Job Name and Number
        CurrentJobNumber = parent.parent.JOBNUMBER;
        CurrentJobName = parent.parent.JOBNAME;
        
        // Open the Page
        var Printleft = (screen.width / 2) - (1100 / 2);
        var Printtop = (screen.height / 2) - (800 / 2);
        window.open('SubmittalPrintEmail.aspx', 'Printpopup', 'menubar=yes,resizable=yes,scrollbars=yes,titlebar=yes,toolbar=yes,height=800,width=1100,left=' + Printleft + ',top=' + Printtop);

        // Get selected row(s) to new grid
        for (i = 0; i < PrintOrEmail.length; i++) {
            var TargetRowId = i + 1;
            var TempStr = PrintOrEmail[i].toString();
            var Vars = TempStr.split(",");

            // [0] = rodID, [1] = colID
            var RowNum = Vars[0];

            // Send rows to gridPrintlogs grid
            grid.moveRowTo(RowNum, TargetRowId, "copy", "sibling", grid, gridPrintLogs);
        }
    }

    if (PrintOrEmail.length == 0 && ChkButton('btn_PrintSubmittals') == true) {
        // Reset button click check
        intCheckButtonHitOnce = 0;
        
        alert('No rows were selected.  You must select at least one row.');
    }

If you want to open grid in new window, its better to serialize grid to xml string and pass it to other window and initialize grid from xml string.

If “gridPrintLogs” is not initialized at the same page as main grid, it impossible to move rows from one grid to another

Olga,

So basically I need to loop through the selected item(s) in the first grid, make a new XML string from it and pass that to the pop-up? I was really hoping the moveRowTo would work and I was just missing something…

So basically I need to loop through the selected item(s) in the first grid, make a new XML string from it and pass that to the pop-up?
You can loop throgh selected items, mark any cell from row changed and serialize grid with “serialize only changed” flag and then pass it to new window.

You can mark cell changed with following code:

grid.cellById(row_id,cell_index).cell.wasChanged(true)

Cool, but I came up with a work around yesterday. On pop-up page load I initialize the grid and then call addRow, and get my values from the original grid. Not pretty, but gets the job done :wink:

Thanks for your help!

for (i = 0; i < opener.PrintOrEmail.length; i++) {
    var TargetRowId = i + 1;
    var TempStr = opener.PrintOrEmail[i].toString();
    var Vars = TempStr.split(",");
    // [0] = rodID, [1] = colID in this instance 19
    var RowNum = Vars[0];

    // Load selected rows from gridSubmittalLog into gridPrintSubLog grid
    gridPrintSubLog.addRow(TargetRowId, "0,0,0,0," + opener.gridSubmittalLog.cells(RowNum, 4).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 5).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 6).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 7).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 8).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 9).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 10).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 11).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 12).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 13).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 14).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 15).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 16).getValue() + "," + opener.gridSubmittalLog.cells(RowNum, 17).getValue() + "," + "0,0");
}