Announcement

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

    Canceling ListGrid selection change

    Hi,

    I'm wondering if there's a way that my application can cancel (or simulate the cancellation of) a selection change in a ListGrid.

    I'm using SmartGWT 3.0 (the dev console version info reads "SC_SNAPSHOT-2011-12-05/LGPL Development Only").

    Here's roughly what I'd like to do:

    Code:
    public class GridView {
        protected void configureGrid() {
            grid.addSelectionChangedHandler(new SelectionChangedHandler() {
                public void onSelectionChanged(SelectionEvent selectionEvent) {
                    if (someCondition) {
                        // do not allow the selection to change, or change it back
                        // part of this logic would ideally use an SC.ask to confirm a change with the user
                    } else {
                        // handle the selection change normally
                    }
                }
            });
        }
    }
    It seems to be the case that the selection changed handler and the selection event classes don't provide a simple call to cancel the selection change. I've looked over the javadocs for SelectionUpdatedHandler and for ListGrid, and I don't see a simple way to catch the selection changes and conditionally prohibit them.

    Has anyone tried anything like this? Is there a simple way that I can maintain some state in my code to handle this case, or some sneaky workaround?

    Thanks!

    #2
    I'm also interested in this. Did you find a workaround?

    Comment


      #3
      Hi guys! Have you found a way to cancel selection change in a ListGrid? Or maybe a workaround?

      Comment


        #4
        I'm also interested in a solution to cancel a selection in list grid.

        Comment


          #5
          We don't currently have a cancellable event to suppress selection change.
          One of the following approaches would probably allow you to do this:

          You could intercept the user action (mouseDown for example) to suppress the event.
          You could set the selectionType to none either temporarily while you want to disallow selection change, or permanently [and if necessary implement your own selection changes directly in response to row-clicks, etc]
          You could track the selection on every change, and if you want to disallow a selection change you could revert to the previously stored selection.


          Regards
          Isomorphic Software

          Comment


            #6
            If only mouseDown event is suppressed, I've seen that selection is still possible using the keyboard, or even the right mouse button.
            We do use this technique in a situation when we want to display some row selected, but to not allow the selection to be changed.

            Would be very good to have a SelectionChangeHandler with a cancellable event.

            Comment

            Working...
            X