Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by C. Bernstein on Apr 06, 2009 07:58
open dhtmlx forum
gridToClipboard() sending rowId to clipboard

When I use gridToClipboard(), the rowIds of each row show up (in excel) as the first column values although they are not displayed on the grid.  How can I make it so that the rowId values do not show up in the clipboard and look exactly like the grid?  Also, since the values are messed up the headers do not match the values when the clipboard data is pasted.
Answer posted by dhxSupport on Apr 07, 2009 02:18

>>When I use gridToClipboard(), the rowIds of each row show up (in excel) as the first column values although they are not displayed on the grid. How can I make it so that the rowId values do not show up in the clipboard and look exactly like the grid?

gridToClipboard() copy to clipboard all grid values including hidden columns. If you have hidden column in your grid you can prevent coping them to the clipboard using method setSerializableColumns(list) where list - list of true/false values separated by comma, if list empty then all fields will be serialized.

>>Also, since the values are messed up the headers do not match the values when the clipboard data is pasted.

gridToClipboard() copy to clipboard all grid rows in such order like them present in the grid. This method can't copy to clipboard grid's header

Answer posted by C. Bernstein on Apr 07, 2009 06:34

I have the following xml:
<rows>
   <row id=1>
      <cell>A</cell>
      <cell>B</cell>
      <cell>C</cell>
      <cell>D</cell>
      <cell>E</cell>
   </row>
   <row id=2>
      <cell>F</cell>
      <cell>G</cell>
      <cell>H</cell>
      <cell>I</cell>
      <cell>J</cell>
   </row>
</rows>

I call grid.load(filename.xml, xml) which puts the xml into the grid.  When
I display the grid the 1 and 2 do not show up and when I call grid.getColumnsNum()
it returns 5.  But when I do grid.copyToClipboard() there are 6 columns with the
1 and 2 in the first column.  I never "hid" the 1 and 2 in the grid; they just never
showed up and it seems from getColumnsNum() that the 1 and 2 values are not in the
grid since the size is 5.  When I try to hide the 1 and 2 using
setSerializableColumns(false, true, true, true, true, true) it still displays the
1 and 2 and hides the values of the first column (A and F do not show up).

Answer posted by dhxSupport on Apr 07, 2009 06:55

Do you mean this column (please see attachment)? 

If yes - this is just row numeration in the Excell.

If no - please provide us any kind of sample where we can reproduce this issue

Attachments (1)
Answer posted by C. Bernstein on Apr 07, 2009 07:23
No, the first column.  I am running searchChava.html
Attachments (3)
Answer posted by C. Bernstein on Apr 07, 2009 07:27
Answer posted by C. Bernstein on Apr 07, 2009 07:27
Attachments (1)
sort.zip98.33 Kb
Answer posted by dhxSupport on Apr 07, 2009 08:25

Add following code to the grid init:

mygrid.enableCSVAutoID(true);

After that gridToClipboard() method will not copy grid's ids to the clipboard.