jvx

How to set column in table not editable


Can I make one or more columns in an UITable not editable but still visible, while all other Columns remain editable?

The setEditable(false) method of UITable works for the whole table, not for just a single column?


Solution

  • The UITable is only one element. If you use an UIEditor the column should also be disabled. The model will handle everything:

    dataBook.getRowDefinition().getColumnDefinition("COLUMN_NAME").setReadOnly(true);
    

    The model notifies all editors and cells in a table. So above method call is enough to change the model and all UI controls will be correct automatically.