javajvx

JVx DataBook readonly except one (few) columns


I have a standard RemoteDataBook in my screen. It has 30 columns and only 3 should be editable. I know that it's possible to set the UITable to readonly:

table.setEditable(false);

But how to make 3 columns editable, because all columns are readonly with editable(false).

I found a code snippet in the documentation:

rdbContacts.getRowDefinition().getColumnDefinition("FILENAME").setReadOnly(true);

but I have 30 columns... and is there a method like setEditable(true);


Solution

  • The framework doesn't offer setEditable(true), but it's easily possible to set only 3 columns editable, just do:

    book.getRowDefinition().
         setReadOnly(ArrayUtil.removeAll(book.getRowDefinition().getColumnNames(), 
                                         new String[] {"A", "B", "C"}));
    

    Another solution:

    book.getRowDefinition().setReadOnly(null);
    book.getRowDefinition().getColumnDefinition("A").setReadOnly(false);
    book.getRowDefinition().getColumnDefinition("B").setReadOnly(false);
    book.getRowDefinition().getColumnDefinition("C").setReadOnly(false);