Question

In a GWT DataGrid I wan to to avoid / prevent the table data rows scrolling in case of some peculiar application status.

I already tried to catch ScrollEvent, but I think that such event was fired “after” rows scrolling has been done.

I also tried to “hide” every “tool” that a user can manage in order to get rows scrolling; so I tried:

.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

and

scrollPanel.removeVerticalScrollbar();

but Mouse Wheel Actions still keep fire rows scrolling ... therefore maybe should be enough to avoid mouse wheel scrolling actions to reach my goal ?

Please note that I don’t want to remove Horizontal Scrolling.

Any suggestions will be appreciated.

Thanks in advance

Was it helpful?

Solution

Here are two solutions. try any one

DOM.sinkEvents(getDocElement(), Event.ONMOUSEWHEEL);

Event.addNativePreviewHandler(new Event.NativePreviewHandler() {

    @Override
    public void onPreviewNativeEvent(final NativePreviewEvent event) {
        if (event.getTypeInt() == Event.ONMOUSEWHEEL) {
            event.getNativeEvent().preventDefault();
        }
    }
});

dataGrid.sinkEvents(Event.ONMOUSEWHEEL);

Not a good solution but still you can try this one also.

dataGrid.addCellPreviewHandler(new Handler<Contact>() {

    @Override
    public void onCellPreview(CellPreviewEvent<Contact> event) {
        dataGrid.getRowElement(0).scrollIntoView();
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top