Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Make some rows of a Grid non editable

Pau Altimiras
6 years ago Aug 12, 2015 2:37pm

Hi,

I am trying to make a grid, from which some rows (based on a property of the row item) are not editable. Is there a straightforward way to achieve this?

I have thought of adding an item click listener that "cancels" the item click event. Is it possible to stop the event from propagating? How?

Thanks in advance.
Best regards,
Pau.

Shadab Ambat
6 years ago Aug 19, 2015 2:53pm
Pekka Hyvönen
6 years ago Aug 20, 2015 6:55am

Howdy. It seems there is no specific API to fit this purpose, but I could achieve the same effect with the following code:

grid.addItemClickListener(new ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                if (isEditable(event.getItem()) {
                    grid.setEditorEnabled(true);
                    grid.editItem(event.getItemId());
                } else {
                    grid.setEditorEnabled(false);
                }
            }
        });

Hopefully this helps.

Pau Altimiras
6 years ago Aug 20, 2015 9:05am
Pekka Hyvönen
6 years ago Aug 21, 2015 7:51am
Pau Altimiras
6 years ago Aug 21, 2015 8:37am
Pekka Hyvönen
6 years ago Aug 21, 2015 9:32am

Seems like there is some issue with attaching/detaching the editor fields.

Because you're running an old version and there has been about a ton of bugfixes for the Grid after that, I'd recommend you to update your Vaadin version at least to the latest 7.4 which is 7.4.8. as it is compatible with 7.4.3.
Or you might even consider updating to the the latest Vaadin which is 7.5.4.

If you still want continue debugging the issue, you could also see from the browser's console if any client side errors are logged there, maybe compile the widgetset with pretty style and enable break on exceptions..

Pau Altimiras
6 years ago Aug 21, 2015 9:35am
Pau Altimiras
6 years ago Aug 21, 2015 1:35pm
Pekka Hyvönen
6 years ago Aug 21, 2015 1:38pm
Shadab Ambat
6 years ago Aug 21, 2015 3:13pm
Michelle Friessen
5 years ago May 19, 2016 8:29pm
Michelle Friessen
5 years ago May 24, 2016 9:06pm