Hi,
I have a strange error that I don't understand. Please view the attached text file for error details.
I have a grid with one column of (mostly) checkboxes. Note these ultracheckbox controls were set manually because the column's data in inconsistent (some cells are blank or contain text). Everything is bound to a manually filled ultradatasource. So far everything works fine.
When a checkbox is checked the SubObjectPropChanged event is caught and used to update the data in the model. The model contains logic to update other data it contains (simple example: checking one checkbox also checks all relevant checkboxes in child objects). These updates need to be reflected in the grid again.
First this was done by replacing all rows in the ultradatasource (it cannot be known how much data has changed so everything need to be updated): This worked ok, but we lost the row expansion state (makes sense because the rows were removed and recreated).
Second solution was to leave the rows in place and set all the cell values (overwriting the old values but maintaining everything else in the grid). This kept the expansion state as desired and updated the rows as desired. All seemed well if not for this one error. It is (occasionally) thrown on this line:
modelCell.SetValue(gridCell.EditorResolved.Value);
I read the editors value and not the cells value because the event seems to be thrown before the cell has been updated; not much of an issue. However at some point (this line is part of a loop) I get this strange error and I don't know why.
Maybe some1 can shed some light on it?
ty,Teun
P.S. Swallowing the exception would "solve" the issue and the code would work as expected but obviously I don't want to do that.
It lloks like there is a bug on the CheckEditor whereby the Value property getter is not throwing an exception when the editor is in not edit mode, so execution proceeds until the GetDataFilteredDestinationValue throws an exception because the 'owner' parameter is null.
For your purposes, this bug is not really the cause of the problem because one way or the other you will get an exception. I'm afraid I was not able to follow exactly what you are trying to accomplish here, but the line of code that is calling UltraGridCell.SetValue would have to change, because you cannot access the editor's Value property unless the cell is in edit mode.
Hi Brian,
Well that confuses me a bit because it works just fine when you swallow this exception. The cell is getting set correctly.
I am uncertain about what the definition of edit mode is, but the cell is not disabled or anything. The user can interact with the checkboxes, so why wouldn't the code be able to?
Although your theory fits with the error showing when replacing the value of a cell it leaves me wondering: If I am doing something wrong, why does it work? Maybe more importantly, how do I do it correctly?
-EDIT 1-
Ok I had another look at the code with a colleague. The things we don't get are:
We also had a look at programmatically setting the control in edit mode when wanted to read its value (even though that doesn't seem to make sense), but this proved excessively complicated. Many parameters were required which we were unable to supply on short notice.
-EDIT 2-
I had a look at this thread: http://community.infragistics.com/forums/t/13965.aspx But setting the Edit mode as seen there didn't solve my problem (at all).
Surely it's possible to simply update the Grid's data programmatically... let alone read it's data. Please help me out here.
grtz,Teun
Teun said:Surely it's possible to simply update the Grid's data programmatically... let alone read it's data. Please help me out here.
Example:this.ultraGrid.Rows[x].Cells["whatever"].Value = "foo";
That solution does'nt work for me.
I populate ultragrid.DataSource with a datatable.
When I try sommething like this this.ultraGrid.Rows[x].Cells["whatever"].Value = "foo";
The system tell me Column "whatever" is read only.
I tryed to put the property readOnly at false for every column of my datatable and even those of my ultragrid.
I tried to update fields directly in my datable.
Nothing to do. It does'nt work.
Do you have any idea?
Atsukami
Hi Atsukami,
I've read this whole thread a couple of times, now, and I'm confused.
1) What is the DataType of this column? Since you are saying you are storing text and other types in the same field, am I correct in assuming that the DataType is object?
2) What control are you trapping SubObjectPropChanged on? I assume it's the grid. But what exactly are you trapping for in SubObjectPropChanged? If you need to change something in the grid data in response to the user changing a field, then that is probably not the best event to use.
It sounds to me like, whatever you are trying to do here, you may be coming at it from the wrong approach or there might be an easier way. But since it's not clear exactly what you are trying to do, it's hard to offer you any advice about what's wrong or how best to achieve what you want.
Perhaps you could start from the beginning and describe what you want to happen here.
The exception you are getting seems to indicate some kind of failure when the CheckBox tries to determine the Value of the cell. But it's impossible to guess why that's the case without more information or a sample project demonstrating it happening.
Are you using a DataFilter here to convert the cell values into something the check editor can deal with?
Is there any threading going on in your application?