Business Pack GridView - AllowEditing

Hi,
Is it possible to dynamically change the AllowEditing property during inline editing or insertion in Business Pack GridView? My point is that if the user, for example, change a value in a certain column, other columns will be made enabled or disabled.

Thanks.

The AllowEditing property cannot be bindable - it tells the GridView that it shall be prepared to switch between ContentTemplate and EditTemplate.

I am afraid that the only way right now is to use the GridViewTemplateColumn and implement this yourself.

Alternatively, you can inherit from the GridViewTextBoxColumn and others, add them Enabled property, and override the BuildEditCell method. In this method, you should call the base, and then do something like this:

var control = (TypeOfControl)cell.Controls[^1];
control.Enabled = Enabled;

The Enabled property must have the data context change attributes, so the binding would be scoped to the current row.

        [CollectionElementDataContextChange(1)]
        [ControlPropertyBindingDataContextChange(nameof(DataSource))]
        public bool Enabled
        {
            get => (bool)GetValue(EnabledProperty);
            set => SetValue(EnabledProperty, value);
        }
        public static readonly DotvvmProperty EnabledProperty
            = DotvvmProperty.Register<bool, TypeOfColumn>(t => t.Enabled);

We may do it in the next release of Business Pack - this can be quite useful feature.

1 Like