I'm trying to figure out the best way to allow users to update a field in an ultragrid that is a read-only expression field in the underlying datatable. For example lets say I have a datatable with 3 columns. Value1, Value2, and Rate. Value1 and Value2 are decimal values and Rate is a decimal expression equal to Value1 / Value2 in the datatable.
Users are allowed to edit value1, value2, or the rate in the ultragrid. To make this work I am hiding the "Rate" field from the ultragrid and added a new editable column to the ultragrid called "RateEditable". When the "RateEditable" field is updated I make the appropriate calculation to update Value1 or Value2. I was hoping there would be a way that I could make the "Rate" field editable and not have the extra field to make this work. Is this possible?
Thank you for your help in advance.
Kurt said:I was hoping there would be a way that I could make the "Rate" field editable and not have the extra field to make this work. Is this possible?
No. Using the unbound column is the best way to go.
Mike, Thank you for your reply. I've run into a problem today and it's related to the solution of the problem explained above. To keep the data in sync I decided to attach a DataFilter to the editable field and when the args direction in the DataFilter is equal to "OwnerToEditor" I return the value of the expression column.
Attached is an example of what I'm doing.
In the project when you click into a "Total Editable" field and then hover over the other Total Editable fields the values start changing unexpectedly. However if you uncomment the code I have in the ultragrid InitializeRow event the Total Editable field displays the expected value.
I believe this is a bug and even though I have a workaround please let me know when this is resolved.
Thanks!
Hi,
You can't have a DataFilter that implements OwnerToEditor without also implementing EditorToOwner. This will result in weird behavior like you are getting here.
But anyway, why are you using a DataFilter at all? I don't understand the purpose of this. InitializeRow is a much better and simpler way to populate your unbound column.