gridToGrid

Hi there,



I would like to use the gridtogrid function to copy the necessary columns to mygrid2 when



<a href=“javascript:mygrid2.gridToGrid(mygrid.getSelectedId(),mygrid,mygrid2)=function(){

return [mygrid.cells(mygrid.getSelectedId(),0).getValue(),mygrid.cells(mygrid.getSelectedId(),1).getValue(),”","","","",""];

});

">Add



is clicked.



I am using mygrid to display products and mygrid2 to act as the shopping cart but cant get the gridtogrid working


This function is used by drag-n-drop functionality but doesn’t do anything itself. So it should be redefined but not called to copy rows.



 



mygrid2.gridToGrid = function(rowId,sGrid,tGrid){
   return [sGrid.cells(rowId,0).getValue(),sGrid.cells(rowId,1).getValue(),"","","","",""];
};



After this using drag-n-drop you’ll get results as expacted. Or you can use moveRow method to move row programatically:



Move It

Thanks,

I have added the code in to the xml of the grid to get it to work as an add to cart link, which adds that row (product) to the 2nd grid (shopping cart)
                print("<![CDATA[Add]]>");
How can I change that last cell to this
<a href=“javascript:mygrid2.moveRow(mygrid2.getSelectedId(),‘row_sibling’,mygrid.getSelectedId(),mygrid)”>Delete
so that I can remove items from the shopping cart?

I managed this with the following function:

    mygrid2.attachEvent(“onRowAdded”,function(rowid)
    {
         mygrid2.cells(rowid,10).setValue("<a href=“javascript:mygrid2.moveRow(mygrid2.getSelectedId(),‘row_sibling’,mygrid.getSelectedId(),mygrid)”>Del")
         return true;
    })