Announcement

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

    reduce threshold for drag scrolling near top/bottom of ListGrid

    The following behaviour is seen when using Using SmartGWT version 2.5 08/02/2011 11:09 LGPL, for all browsers:

    We have enabled drag text selection within a ListGrid via:

    this.setCanDragReposition(false);
    this.setCanDragResize(false);
    this.setCanDragRecordsOut(false);
    this.setCanDragSelect(false);
    this.setCanReorderFields(false);
    this.setCanReorderRecords(false);
    this.setCanSelectText(true);
    this.setCanDragSelectText(true);
    this.setDragAppearance(DragAppearance.NONE);

    This ListGrid runs almost the entire height of the page so it can be quite tall. We have found that when selecting text near the top and bottom of the ListGrid that as the user selects the text there is very fast scrolling up (if the text selection is near the top) or scrolling down (if the text selection is near the bottom). This scrolling is so fast that the user looses control over the text that is being selected and is unable to effectively complete this task.

    Looking at the underlying SmartClient (ISC_Core.js) script I can see that if the user drag selects within a region that is 10% of the total height of the underlying Canvas at the top or bottom that this automatic scrolling will occur:

    dragScrollThreshold:"10%"

    and that the maximum scroll increment is 5%:

    maxDragScrollIncrement:"5%"

    Both of these are marked "@visibility internal" and I am unable to find any matching methods within SmartGWT (for example on Canvas.java) that would allow reducing these values to say 2% and 1% respectively which likely is more appropriate for our particular ListGrid.

    Is there a supported/correct way of:

    1. Reducing the region at the top/bottom of the ListGrid where this automatic scrolling starts

    2. Reduce the rate at which the scrolling occurs when automatic scrolling is performed.


    Thank you for any help/hints.

    #2
    Those properties are in fact not documented because we plan to revise the system to avoid this very issue..

    For an undocumented property like this, you can use setAttribute() in SGWT to set it, eg setAttribute("dragScrollThreshold", "5%"). So you can use this to adjust the existing properties and this issue will go away in some future version.

    Comment


      #3
      Found that setting the attributes directly against the class extending ListGrid was ineffective. Using SmartClient Development Console determined that the object handling the scrolling event was the renderer for the ListGrid rather than the ListGrid itself.

      ListGrid exposes the getGridRenderer() method to provide access to the underlying renderer, but unfortunately the setAttribute method isn't public. Looked at the implementation for setAttribute and it appears to be trying to handle the case where the underlying SmartClient peer object hasn't been created yet, if it has been created then it just uses setProperty which is exposed.

      After ensuring that the configuring of these thresholds occur after the renderer for the grid is created, setting the appropriate properties addressed this problem.

      Comment


        #4
        Fix works! No more scroll jumps

        cthomson - Thank you for posting this issue AND, more importantly, your resolution. It helped me fix the exact same issue that my client encountered and that was driving them crazy. Whenever they tried to select text in a grid in the first or last row, the grid would 'jump/scroll' way up or down. They could never select the first or last line of grid text.

        Isomorphic - Any ideas when this issue will be resolved within the framework?

        Here was my final 'fix':

        Code:
        table.addDrawHandler(new DrawHandler() {
           public void onDraw(DrawEvent event) {
              if (table.getGridRenderer() != null) {
                 table.getGridRenderer().setProperty("dragScrollThreshold", "2%");
        					         table.getGridRenderer().setProperty("maxDragScrollIncrement", "1%");
              }
           }
        });

        Comment

        Working...
        X