My grid is bound to my data/business objects. All works well. I can add/remove/etc. I can even copy and paste a single cell value with no real problems. The UltraGrid updates my underlying business object property for the column that has been pasted into. Even when the column is bound to a list of objects using an UltraCombo I can copy a string to this column and that works too.
I was looking at the following issue but there was no real followups:
http://es.infragistics.com/community/forums/p/45867/247538.aspx#247538
The problem I get when I try and paste to multiple cells - which a bound to a list of my business objects. I have 2 rows in the grid with existing data there. I have copied the following data from the table (2 rows, 2 columns):
When I select the same cells to paste into, I get the following error (I can see more information in the Error event):
Error performing Paste operation. Further information: Unable to convert the value 'SW 1 + SW 2' to the column's data type: Illegal data value Continue with the remaining cells?
All works fine when I paste the above one by one.
Why would a multi cell operation fail, but the single cell would work? Any ideas where I should look to help with this?
Thanks,
Andez
Hello ,
Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
Hi Hristo,
I've been trying to get a working solution (on back burner in my spare time).
What you've suggested is exactly what I was looking for. I was just trying to make it work before confirming. I think I have - I just wanted to do more tests.
Hello,
I am just checking about the progress of this issue. Let me know If you need my further assistance on this matter?
UltraGrid will not automatically cast object of ValueList<Type1> to ValueList<Type2>, so you could handle BeforeMultyCellOperation event of UltraGrid. Argument of this event will returns you Cells that are involved in the MultyCellOperation (if you perform Paste, those will be the cells which should changes their values) and list of new values (e.NewValues(UltraGridCell), where cell from e.Cell collation is key for e.NewValues collection), which should be assigned to the cells involved in MultyCellOperation. So based on the ValueList<Type1>, which will be value in e.NewValues, you should generate ValueList<Type2> (which is the type of the destination cell). Here is pseudo which you could use to develop your code for BeforeMultyCellOperation:
‘Check if user performs Paste
If e.Operation = MultiCellOperation.Paste Then
‘ Loop trough the cells
For Each cell As UltraGridCell in e.Cells
If TypeOf cell.Column.DataType IsNot GetType(e.NewValue(cell).Value) And TypeOf cell.Column.DataType is ValueList<Type1> Then
Dim vl1 = DirectCast(e.NewValue(cell).Value, ValueList<Type1>)
e.NewValue(cell).Value = GenerateValueListOfType2( vl1)
End If
Next
I hope that this will helps you.
Please let me know if you have any further questions.
My classes are marked as Serilizable - they were generated using nHydrate which is a thin layer on top of the Entity Framework.
I think it might be down to having 2 columns - where column 2 is dependant upon the selected item in column 1. Both columns are bound to different lists of business objects - so column 1 is bound to a list of BusinessObject1 and column 2 is bound to a list of BusinessObject2. These are selected in two different UltraCombo's.
But for my sake, I am copying valid data. I think the issue is that because the data for both columns comes from two different lists, I need to initialize them somewhere. At the minute I set the data source on my combos in BeforeCellListDropDown based on the e.Cell.Column.Key. All works well when I just edit the data myself.
So in Grid_InitializeLayout I set the following:
e.Layout.Bands(0).Columns("BusinessObject1").ValueList = BusinessObject1Combo
e.Layout.Bands(0).Columns("BusinessObject2").ValueList = BusinessObject2Combo
If I cause the UltraCombo's to be displayed, then the copy and paste works fine. I just want to copy and paste and for the appropriate list value to be selected.
Any more thoughts?
Thanks