Announcement

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

    ListGrid::scrollToRow (without fixed record heights)

    Hi together,

    the SmartGWT version of scrollToRow does not work on listgrids without fixed record heights (listGrid.setFixedRecordHeights(false)).

    While the JS function scrollToRow works perfectly, the GWT version does not use it for whatever reason. Instead it tries to calculate scrolling itself, using a common cell height. As we configured the listgrid to use different record heights, the listgrid can't scroll to the expected row.

    Code:
        original ListGrid.java
    
       /**
         * Scroll to the specified row number.
         *
         * @param rowNum the row num
         */
        public void scrollToRow(int rowNum) {
            int cellHeight = getCellHeight();
            scrollBodyTo(null, (rowNum - 1) * cellHeight);
        }
    Following workaround gives the expected result:

    Code:
        class ScrollableListGrid extends ListGrid {
            @Override
            public native void scrollToRow(int rowNum) /*-{
                var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                self.scrollToRow(rowNum);
            }-*/;
        }
    Any chance to get a working version without workaround?
    Last edited by ect; 24 Sep 2012, 23:54. Reason: clarifications

    #2
    A quick note to let you know we will be making a change to address this and will update this thread when the change is in place - however your workaround should be fine until we have updated the framework code

    Regards
    Isomorphic Software

    Comment


      #3
      Originally posted by ect View Post
      Hi together,

      the SmartGWT version of scrollToRow does not work on listgrids without fixed record heights (listGrid.setFixedRecordHeights(false)).

      While the JS function scrollToRow works perfectly, the GWT version does not use it for whatever reason. Instead it tries to calculate scrolling itself, using a common cell height. As we configured the listgrid to use different record heights, the listgrid can't scroll to the expected row.

      Code:
          original ListGrid.java
      
         /**
           * Scroll to the specified row number.
           *
           * @param rowNum the row num
           */
          public void scrollToRow(int rowNum) {
              int cellHeight = getCellHeight();
              scrollBodyTo(null, (rowNum - 1) * cellHeight);
          }
      Following workaround gives the expected result:

      Code:
          class ScrollableListGrid extends ListGrid {
              @Override
              public native void scrollToRow(int rowNum) /*-{
                  var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                  self.scrollToRow(rowNum);
              }-*/;
          }
      Any chance to get a working version without workaround?
      How did you made it? I'm trying to do exactly same thing, but only thing I get is
      com.google.gwt.core.client.JavaScriptException: (TypeError): self.scrollToRow is not a function

      My code:

      Code:
      		listGrid = new ListGrid() {
      		
      			@Override
      		    public native void scrollToRow(int rowNum) /*-{
      		        var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
      		        self.scrollToRow(rowNum);
      		    }-*/;
      				
      		}; 
      
      ...
      
      
      		listGrid.scrollToRow(rowNum);

      Comment


        #4
        Maybe you are using a different version? At least, the smartgwt 3.0 stream has such a function from release version up to most recent nightlies. Just double check the ListGrid.js code (contained in the smartgwt.jar under com/smartclient/debug/public/sc/client/widgets/ListGrid.js).

        Comment


          #5
          Originally posted by ect View Post
          Maybe you are using a different version? At least, the smartgwt 3.0 stream has such a function from release version up to most recent nightlies. Just double check the ListGrid.js code (contained in the smartgwt.jar under com/smartclient/debug/public/sc/client/widgets/ListGrid.js).
          Thanks!

          In fact I thought I was using SmartGWT 3.0. But for that project, I wasn't. :)

          Comment


            #6
            Just a quick follow up note to let you know that scrollToRow() has been reimplemented in 3.1d and (as of the next nightly build) the JSNI workaround to call the SmartClient equivalent method will no longer be necessary.

            Comment

            Working...
            X