Announcement

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

    TreeGrid Request

    We are currently using SGWT 4.1p.

    I am trying to create a TreeGrid implementation similar to that found in the Google Earth Client for Google Earth Plugin. I am using cascading checkboxes for selecting the visibility of features on the globe.

    The issue is that if a folder contains hundreds of child nodes, and you toggle the visibility of the folder, there is no mechanism for capturing just the element that was deselected. Iterating over the entire tree and kml dom is incredibly expensive and locks the browser for several minutes.

    I have read through the api and attempted overriding RecordClick, RowClick, as well as addingRecordClickHandler along with calling isCheckbox to no avail. I have also debugged extensively how SelectionChangedHandler, and SelectionUpdatedHandler work.

    The best mechanism I have found is that a SelectionChangedHandler will fire with the clicked elements initial state first, I can then ignore all further SelectionChangedEvents, until the SelectionUpdatedEvent is fired. However, this implemenation is entirely dependent on your API not changing in any further updates.

    Due to the nature of how the kml dom handles visibility, making a parent container invisible hides all of its children, which is a very cheap operation and allows me to ignore the state of all of its children.

    Is there any way that you could provide a mechanism for adding a click handler to the selection element in the tree grid? Or a similar hack like we used to do in order capture remove events, by creating a field marked as the remove field that we can then add a handler to?

    #2
    We're not really following the issue here.. why wouldn't you just:

    1. note down the clicked record any time recordClick fires and it's in the checkbox cell

    2. look at this information the next time SelectionUpdated fires

    Comment


      #3
      The problem with overriding recordClick is that it is never being executed.

      Comment


        #4
        Uhhh.. you'll need to elaborate on that, RecordClick is an API used in dozens of samples, and it seems to be working fine :)

        Maybe you are saying it doesn't fire early enough? It's true that mouseDown may be the event that fires at a more appropriate time.

        Comment


          #5
          Here is my implementation.

          The log statement never occurs, and the value is null when passed to the listener.
          Last edited by jpappalardo; 24 Sep 2014, 09:02.

          Comment


            #6
            For the sake of my own sanity I have also tried just adding a RecordClickHandler, which does fire when selecting the name field...the other two fields do not exist in this particular instance. However, it does not fire when clicking on the expansion component or the checkbox.

            Comment


              #7
              Please try the MouseDown event as previously mentioned.

              On further consideration, the approach we recommended is right in general, but RecordClick is both too late and designed not to fire when grid built-ins (such as checkbox selection) have already handled the event.

              Comment


                #8
                Again it only fires on the ListGridField and I am not sure how it would be helpful since the events source is the TreeGrid, not a field.

                Comment


                  #9
                  Not sure what you mean - MouseDown is an event on Canvas, so it fires on any Canvas.

                  Comment


                    #10
                    I attempted TreeGrid.addMouseDownHandler as I dont really know what else to attach the handler to, in this case the mouse down events source is the TreeGrid itself, and only fires when clicking on the name field.

                    Comment


                      #11
                      Sorry for the confusion - because the checkbox column completely handles the mouseDown event, it is not bubbled. This is a best practice to avoid two components reacting to the same event when it's not appropriate.

                      The same general approach applies though:

                      1. note down the row number that was clicked when SelectionChanged fires

                      2. take action only in SelectionUpdated, but using the coordinates you recorded in SelectionChanged.

                      Comment


                        #12
                        Using cascading selection actually causes problems here. I select/deselect a leaf node, where all nodes were initially visible will cascade from the root node to the leaf node being last. Subsequent changes to a leaf node will only fire for that leaf, unless it returns you to a state of all selected/deselected which will then cascade events from the root back down to the leaf. What happens when you select a folder one or two levels into the root node is even more difficult to discern.

                        SelectionChangedEvent.getSource returns the tree rather than the field that caused the event. There is no method for retrieving the row number that initiated the event, there is simply a getX and getY.

                        Do you have any other suggestions of how I could simply know the record that sourced the cascade of events?

                        Comment


                          #13
                          Just use treeGrid.getEventRow(), this works no matter what event is currently being processed.

                          Comment


                            #14
                            Thank you, that was exactly what I was looking for

                            Comment

                            Working...
                            X