Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Is there a simple way to confirm/cancel listgrid clicks

    Hi, playing around with a feature request we got today.

    Basically, i'm wondering if there is any way to cancel clicks on a grid. For example, say i want to throw up a confirmation dialog every time a row is clicked in a grid, and only change the selection in the grid if the user clicks yes in the confirmation dialog.

    I tried cancelling the events in clickhandler and selectionchanged handler, but that didn't do much. Is there something else that can be done here?

    #2
    I got it working with a rowdownhandler and then a selectionchanged handler. For reference code below (and if you have a better way, feel free to point out my mistakes!

    Code:
            grid.addRowMouseDownHandler(rowMouseDownEvent -> {
                rowMouseDownEvent.cancel();
                SC.ask("Sure?", "Yeah", aBoolean -> {
                    if(aBoolean){
                        GWT.log("YEAH, lets do rowclick!! row " + rowMouseDownEvent.getRowNum() + ", col" + rowMouseDownEvent.getColNum());
                        grid.selectSingleRecord(rowMouseDownEvent.getRecord());
                    }
                });
            });
    
    grid.addSelectionChangedHandler(selectionEvent -> {
                GWT.log("selection changed!!");
                if (grid.getSelectedRecord() != null) {
                    details.showItem(grid.getSelectedRecord());
                    showDetailPane();
                }
            });

    Comment

    Working...
    X