Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ralph on Apr 10, 2009 15:29
open dhtmlx forum
copyBlockToClipboard and pasteBlockFromClipboard error

I'm trying to setup mygrid to allow for copy and paste based on your example:

http://dhtmlx.com/docs/products/dhtmlxGrid/samples/clipboard/grid_selection.html?un=1207298932000


I added the onKeyPressed function, I added

mygrid.enableBlockSelection(true);
mygrid.attachEvent("onKeyPress",onKeyPressed);

and I can highlight a selection of cells, but whenever I try to copy I get an IE error "Object doesn't support this property or method". Is this part of a professional only or do I have a configuration conflict?

Thanks for your assistance.
Answer posted by dhxSupport on Apr 13, 2009 01:37
To use enableBlockSelection() methos you should to include file dhtmlxgrid_selection.js which is part of standard version
Answer posted by Ralph on Apr 13, 2009 09:05
I'm using that,

<script src="codebase/ext/dhtmlxgrid_selection.js"></script>

but it still doesn't work. As soon as I press Ctrl-C or Ctrl-V it fails.

function onKeyPressed(code,ctrl,shift){
    if(code==67&&ctrl){
        mygrid.copyBlockToClipboard()
    }
    if(code==86&&ctrl){
        mygrid.pasteBlockFromClipboard()
    }       
    return true;
}

It seems to fail on the mygrid.copyBlockToClipboard() statement.

I tried removing that line and replaced it with alert('hi'); and that worked.

Thanks
Answer posted by dhxSupport on Apr 14, 2009 02:07
To use operation with clipboard you also should attach file <script src="../codebase/ext/dhtmlxgrid_nxml.js"></script>
Answer posted by Ralph on Apr 14, 2009 07:46
That was the missing piece. Thanks! Was that in the documentation somewhere?
Answer posted by dhxSupport on Apr 14, 2009 08:35
You can check what file does method require here http://dhtmlx.com/docs/products/dhtmlxGrid/doc/alpha.html#grid_api_a
Answer posted by Ralph on Apr 14, 2009 10:52
The copying works well and I paste it into Excel fine, but it doesn't copy the background colors or formating. Is  there a way to do that?

Thanks
Answer posted by dhxSupport on Apr 15, 2009 08:23
Unfortuanately there is no way to copy row's style to the csv format. You are able to copy just cell's values
Answer posted by Ralph on Apr 15, 2009 08:33
Thanks for letting me know.