Hi,
I've ultrawebgrid in my application where i can copy data from Excel and paste in it therby for validation and submission.
I'm having 16 columns in the grid out of which, for 3 columns no data are entered in the grid as they re only read-only fields in the Ultrawebgrid.
So in Excel, I'm having data for only 13 columns and 3 other columns(read-only in the grid) are just hidden in Excel sheet.....
So when i copy these data from Excel and paste in the grid, I want the data from respective columns (in Excel) to get pasted in the respective columns in the grid::
How can i check this??? Can anyone help with this copy/paste operation????
Can som1 plz help.... URGENT..........
Try this code
function UltraWebGrid1_BeforeClipboardOperation(gridName,operationType,options )
{
if(operationType != igtbl_ClipboardOperation.Paste)
return true;
}
var copiedData = igtbl_getClipboardData();
var copiedCellValues = copiedData.split('\t');
if(copiedCellValues.length != 13)
alert('Wrong paste');
var grid= igtbl_getGridById(gridName);
var band = grid.Bands[0];
var row = grid.getActiveRow();
var gridCellNum = 0;
var copiedValNum = 0;
while(copiedValNum < 13 )
/*Paste if cell is not read only*/
if(band.Columns[gridCellNum].AllowUpdate != 2)
row.getCell(gridCellNum).setValue(copiedCellValues[copiedValNum++]);
gridCellNum++;
Let me know if this is helpful to you.
You need to replace 8 with 13 in both the comparasion.
It is the number of columns in Excel.
thnk u HBA. u really helped me through ...... I was v.new to javascript too...... Ur solution works v.fine...
small discrepancies in that .....
When i assign values for every column i found tht '\r' gets appended to each string which i enterd..
Suppose i have given a value called "N" for a column in the grid . then when i check it in code behind i could see the value assigned as "N\r" as this character gets appended...
1) May i know how does this happen and how to block this????
2) in my grid when rows are added using the sttmnt row.nextrow() .. at the bottom in the grid, one extra empty row also gets added to which is needless.....i.e. When i have 20 rows in Excel and try to paste in grid, 21 rows are created in grid out of which the last one is empty row and needless
How can i prevent this.... i mean i need to have only as many rows as equal as in Excel when i copy/paste.....
Do you get '\r' for every column or for Last column only? I am getting it for last column only.
If your are getting '\r' in last column then you can try following change.
Try with replacing copiedData.split (‘\n’) with copiedData.split('\r\n').
Otherwise, create a .txt file, paste the excel row and attach it with the case. I want to check it.
Also let me know which version of Excel and windows do you use? At my end I am not getting extra row. Have you done any change in code?
Thnk U HBA.... U helped me at this urgent time... and i was quite new to these stuffs too :).... I corrected the mistake ...now everything works fine. so no problem with the Excel....
Can u also plz help me in this post too??
http://forums.infragistics.com/forums/p/25940/95147.aspx#95147
Sure. I will look into that.
Could you mark all your solved queries as “verified”? Just click “Verified” button on the correct answer.
It would help other people to use the solution.