Grid setEditableField

Hi,

i used the
addressbook
example and wanted to add “special” editor fields like in the
Grid Editor example
.
When i extend the addressbook example with code from the grid editor example it does not work.
For Example using a Slider to edit a Number Value.
However when i use a seperate grid (not from the addressbook) example, a new one without a data source and just addColumn to create new columns, the same Code for the Slider to edit Number values works fine.

In the case where it doesnt work I dont get an error or anything, its just like i didn’t set the editor field.

Is there something going on in the background that i miss??

Thanks in advance

PS: i mean “setEditorField” and not “setEditableField”!

It’s hard to say what’s the problem without seeing some code. You could be setting the data source or something else in wrong order, or some other issue.

public class DemoUI{
Grid grid1 = new Grid();
Grid grid2 = new Grid();

protected void init(VaadinRequest request) {
configureComponents();
buildLayout();
}

private void configureComponents() {
    Slider progressEditor = new Slider();
    progressEditor.setWidth(100.0f, Unit.PERCENTAGE);
    progressEditor.setMax(150.0);
    progressEditor.setMin(1.0);

    grid1.setEditorEnabled(true);
    grid1.setSelectionMode(Grid.SelectionMode.NONE);
    grid2.setEditorEnabled(true);
    grid2.setSelectionMode(Grid.SelectionMode.NONE);

    grid2.addColumn("col1", Double.class).setEditable(true).setEditorField(progressEditor);
    grid2.addRow(1.0);
    grid2.addRow(2.0);

    grid1.setContainerDataSource(new BeanItemContainer<>(MyRow.class));
    grid1.getColulmn("col1").setEditable(true).setEditorField(progressEditor);
    refreshRows();
}

public void refreshRows(){
    grid1.setContainerDataSource(new BeanItemContainer<>(
        MyRow.class, serviceMyRows.findAll()));
}
....

}

I am sorry for the CodeLayout, i dont know why the editor removes my whitespaces if i have “Sorucecode” selected in the RTE.

The only difference is that in one case I add the rows directly to the grid an in the other case i service which loads all rows from the database.

Thanks again for the help!

Ahh, I just found out that after re-setting the DataSource the editorField settings are rest, even if my other settings (like renderers, column orderings, …) are still there.

Yes, that’s one thing. Another is that you’re using the same editor component instance in both grids.

The single Editor Component was just to keep the sample code as small as possible.
The only problem was that using a new BeanItemContainer reset my previous configurations.

Thanks!

Closed.