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.
This is really good HBA.... but it works only for 1 row.... i mean when i copy when i copy bunch of rows frm Excel to grid. it's only the first row data getting pasted correctly in appropriate columns.... other rows are not considered.
What i can do ???? Pls reply
Does your paste insert new rows? Or it just replaces data in existing rows?
Consider this:::
in Excel I'm having 5 rows each with sum no of columns (say a finite no: 10) and when i paste in the grid it's only the first row getting copied (as in the above code)...... now wat can i do to copy multiple rows each with value for the columns.........it's something to do with the split operation!!
and I should be able to paste in the grid.......
I am updating the code and post in some time but I need to know following.
What should happen if you copy 10 rows from excel and your grid only have 6 rows?
Should other 4 rows be newly created and inserted in the grid as new rows or they should be simply ignored?
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.
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
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 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.....
You need to replace 8 with 13 in both the comparasion.
It is the number of columns in Excel.