Lock columns in table field

Description of the limitation and why it is relevant to address

As a dev I want to create a table field with certain columns and/or cells locked, such that the user can’t change them.

A typical example is the table with the lap and anchorage lengths for different steel rebar diameters. The user should be able to change the lengths, but not the diameters.

Submitter proposed design

In the example of the lengths table defined as:

project.tab = vkt.Table("", default=default_lengths)
project.tab.diam = vkt.AutocompleteField("Diamètre", options=HA_diam)
project.tab.L_lap = vkt.IntegerField("Lap length")
project.tab.L_ancr = vkt.IntegerField("Anchorage length")

diam must be locked, L_lap and L_ancr are modifiable by the users.

Implementation suggestions:

  1. Add a new is_locked boolean argument to each field that can be used in a table. If is_locked=True, the user can’t change the value from the default value.
    → Ex: project.tab.diam = vkt.AutocompleteField("Diamètre", options=HA_diam, is_locked=True)
  2. Add a new locked_columns list argument to vkt.Table, which takes the name(s) of the columns to be locked.
    → Ex: project.tab = vkt.Table("", default=default_lengths, locked_columns=["diam"])

Current workarounds

Add a validation on_next step to confirm that the user didn’t change the field(s) which shouldn’t be.

Hi @RemiPelletier ,

Thank you for posting this. I agree that sometimes you want to make a field only viewable, and that this is not only limited to the TableView. There is a separate issue on this here:

In this issue, the proposed solution looks very similar. Do you agree?

1 Like

Hi Marcel, yes you’re absolutely right.