Simple implementation to edit a row

Hello,

As all cells in a table can be editable after call “table.setEditable(true)”, I wonder whether there is a simple implementation for a row to be editable. For example, I just want to input a new row or edit a selected row in a table.

Thanks,
Watt

If I understand it right, you just want to have one row editable, and all others as non-editable?

not tested, but something like this:


        table.setTableFieldFactory(new TableFieldFactory() {
            public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
                boolean rowIsEditable = true; // check itemId if row should be editable
                
                // editable, return default edit field
                if(rowIsEditable) {
                  return DefaultFieldFactory.get().createField(container, itemId, propertyId, uiContext);  
                } 
                
                // not editable, return null
                return null;
            }
        });

Of course you have to add the logic to determine if the row with the given itemId should be editable.

greetings
Peter

Great, it works! Thank you.