Announcement

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

    Timing of DrawHandler.onDraw()

    I know a DrawHandler's onDraw() method will be called when the widget is being drawn. But precisely this is before or after the widget is drawn? I am asking this question because I have a TreeGrid and I want it to be fully opened.

    The suggested method is

    Code:
    treeGrid.getData().openAll()
    However, I observed if I put the above call into a DrawHandler's onDraw() method, the tree would NOT be opened. To make it open, I have to use a Timer to schedule the call some time (say 500 millisecs) later. It looks to me that when the call is made in the first case, treeGrid has not been fully drawn so the openAll() call arrived too early.

    I saw people posting code using the above method (not using a Timer). E.g. Example 4 on this page:

    http://www.programcreek.com/java-api...ts.DrawHandler

    But it did not work for me and I have to resort to using a Timer. I want to avoid using a Timer.

    #2
    This has nothing to do with the timing of drawing, but actually with when data is loaded. You most likely need to wait for the DataArrived event before attempting to open the tree.

    Comment


      #3
      Thanks! I changed to use DataArrivedHandler and it works as expected.

      P.S. For anyone who are new to DataArrivedHandler ...
      Code:
      /*
       * Do not confuse the event/handlers in the two packages
       */
      //import com.smartgwt.client.data.events.DataArrivedEvent;
      import com.smartgwt.client.widgets.tree.events.DataArrivedEvent;
      //import com.smartgwt.client.data.events.DataArrivedHandler;
      import com.smartgwt.client.widgets.tree.events.DataArrivedHandler;

      Comment

      Working...
      X