How to make some table rows editable and others read-only?

In my application, I want to disable editing of a row in a table if certain conditions are met. I saw “addEnabledRule” in the BaseAction class but that seems to apply to buttons attached to tables. I want to set editable(false) for columns in certain rows and editable(true) for others.
I tried this on the datasource attached to the table, but it does not work. I can still modify the rows that should be read only.


        updtransDs.addItemPropertyChangeListener(e -> {
            Updtrans updtrans = e.getItem();
            if (updtrans != null) {
                pinTable.scrollTo(updtrans);
                if (updtrans.getUpdatedate() != null) {
                    pinTable.getColumn("mailfile").setEditable(false);
                } else {
                    pinTable.getColumn("mailfile").setEditable(true);
                }
            }
        });

Can this be done? How can I make some rows readonly and others editable?

Hi,

It is not supported by editable tables and the only way to achieve this is to use your own generated columns (see https://doc.cuba-platform.com/manual-6.4/gui_Table.html). You need to implement column generators that will show either editable Field or read-only depending on your business logic. For your case I would recommend simple Master-Detail screen instead of inline editing, since it is more convenient if you have such a dynamic editing logic.