Announcement

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

    Rebinding event handler function. Is it possible?

    Hi, I'm asking if it is possibile to rebind an event handler function after a component has been constructed.
    In my example I need to rebind the recordDoubleClick event of a grid to a different callback function if some condition occurs.
    Is it possibile? What is the correct syntax for doing so?

    Thank you.

    #2
    Hi lveronese,

    I never did this, but I think it is possible. In SmartGWT you get a com.google.gwt.event.shared.HandlerRegistration that has a removeHandler as return value for addDoubleClickHandler.
    I assume that in SmartClient there will be a similar functionality. Otherwise you could make you eventHandler handle both cases with an if, couldn't you?

    Best regards
    Blama

    Comment


      #3
      Well, it's not that simple but I can refactor the code to avoid the rebinding. Anyway in the doc I didn't find a way to register or unregister event handlers which is normally a common feature.
      This was the reason I asked.
      Thank you.

      Comment


        #4
        I don't know if there's a better way, but using SmartClient I would simply do:

        Code:
        grid.addProperties({
          recordDoubleClick:function(viewer, record, recordNum, field, fieldNum, value, rawValue){
            // a new callback
          }
        });
        or, as a string method:

        Code:
        grid.addProperties({
          recordDoubleClick:"aNewCallback()"
        });

        Comment


          #5
          Thank you. I refactored the code but just in case I need this in the future it may come handy.

          Comment

          Working...
          X