We are not able to cut and paste from excel where we have comma separated values. We have used the /t delimiter as advised but still the left truncation from the comma position is what is getting copied. Please advise on us on how to handle this and the main facility of copying values from excel will be lost if we are not able to do this function.
We have used the /t delimiter a
The correct delimeter is \t
grid.setCSVDelimiter("\t")
If problem still occurs for you - please provide a js code which was used for grid initialization, because we can’t reconstruct problem with local samples.
The following is the code for initialising the grid
mygrid.setHeader(“Grades,Comments,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Jan,Feb,Mar,Total”);
mygrid.setInitWidths(“60,80,60,60,60,60,60,60,60,60,60,60,60,60,85”);
mygrid.setColTypes(“ro,txt,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ro[=c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12+c13]”);
mygrid.setColAlign(“left,left,right,right,right,right,right,right,right,right,right,right,right,right,right”);
mygrid.setColSorting(“str,str,int,int,int,int,int,int,int,int,int,int,int,int,int”);
mygrid.setSkin(“modern”);
mygrid.init();
mygrid.setOnEditCellHandler(doOnCellEdit);
mygrid.setOnKeyPressed(onKeyPressed);
mygrid.enableBlockSelection();
mygrid.attachFooter(“Total,#cspan,
mygrid.loadXMLString(xmlStringforGrid,calculateFooterValues);
“xmlStringforGrid” is the xml string for grid loading.
function onKeyPressed(code,ctrl,shift){
if(code==67&&ctrl){
mygrid.setCSVDelimiter("\t")
var csvNew = mygrid.serializeToCSV();
mygrid.copyBlockToClipboard();
}
}
Please check attached sample, it uses the same initialization code as in your case and there is no any problem to copy comma separated values from excel or into excel.
1208435053.zip (98.3 KB)
Sorry, it didnt work with excel
Is there anything else to be modified other than setting CSV Delimiter to “\t”?
Sorry, it didnt work with excel
Can you provide mode details, please.
Which version of Excel you are using and which data exactly can’t be copied.
The same sample works fine in local test, while coping data with commas from grid to Excel, or from Excel to grid.
>>Is there anything else to be modified other than setting CSV Delimiter to "\t"
This is the only necessary step.
I tried changing the column sort criteria from “int” to “str”.
The code change was:
mygrid.setColSorting(“str,str,str,str,str,str,str,str,str,str,str,str,str,str,str”);
Then i could copy from Microsoft excel to dhtmlxtreegrid. But the row wise sum(ie, the column “Total” gives me “NaN”…perhaps, due to the “,” .How can i get the rowwise total also in a “comma separated numerical value” format?
So the problem is not in the incorrect data, but in not processing results of paste as int values, right ?
The problem is that grid can’t recognize is inserted value a number with comma separated digits which need to be processed or just a string which must be set untouched.
While it not possible to do necessary conversion automatically it possible to implement necessary logic by using onRowPaste event - you can get the pasted value and replace the comma in it, so it will be correct for any in-grid math operations.
Please check attached sample.
1209136821.ZIP (1.93 KB)