Cell level ReadOnly

All viewModelColumns check for a sibling column with the same name <Name> postfixed with _ReadOnly

If this <Name>_ReadOnly column is found its expression should evaluate to bool and will be used as the ReadOnly status for the column <Name> instead the <Name>-columns own ReadOnlyExpression.

Why is this needed?

The columns owned ReadOnlyExpression is cursored - meaning it uses the context of the root in the viewmodel and it has the same value through out the ViewModel.

If you have ListView or DataGrid you may want to control readonly on a per cell level - and that is not possible with the ReadOnlyExpression - since it will not have the context of the row but rather the context of the ViewModel.

When you have this situation you can use the <Name>_ReadOnly extra column.

Gotchas and complicating factors

If you have <Name>_ReadOnly column set to an expression vReadOnly for example - were vReadOnly is a boolean variable you should be aware that the expression may be changed by the runtime to something more complex.

If you have the GlobalReadOnly mode on - the runtime will rewrite your expression "vReadOnly" to "vSysReadOnlyMode or (vReadOnly)".

This will make the <Name>_ReadOnly follow the rules stipulated by the GlobalReadOnlyMode - but it will also make your expression immutable to a UI.

If you have chosen to also display the <Name>_ReadOnly column in the UI "not visible=false"...

x

...you will experience that the checkbox becomes impossible to edit when you have the GlobalReadOnlyMode on - due to the fact that even if this expression "vReadOnly" is mutable this expression "vSysReadOnlyMode or (vReadOnly)" is not.

This page was edited 15 days ago on 08/30/2024. What links here