Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:37:33+00:00 2026-06-04T05:37:33+00:00

I’m trying to get a dataview to scroll to specific places. I’m testing this

  • 0

I’m trying to get a dataview to scroll to specific places. I’m testing this in Chrome. I have a scrollToSelected() method in my dataview which calculates where to scroll to and then calls:

var scroller = this.getScrollable().getScroller();
scroller.scrollTo(0, y, true);

This works when I select list items that trigger my scrollToSelected() method. But at the point of showing the dataview for the first time I select(id), which also triggers scrollToSelected(). The variable y is calculated properly, but the scrolling doesn’t happen. So I added a scroller.refresh() to the code before the scrollTo(), and now it works. But ONLY when Chrome’s development toolbar is open. If I open the page when the developer toolbar is not there, the scroll never happens. Any ideas?

Edit:
Some more code if it helps. Please forgive any glaring architecture faults – Sencha is quite a different coding paradigm for me. That said, suggestions welcome.

Ext.define('NC.controller.Cook', {
  extend: 'Ext.app.Controller',

  config: {
    control: {
      stepsPanel: {
        swipe: 'stepSwipe',     // this will eventually call goToStep
        selectStep: 'goToStep' // if the user directly selects a step (by tap), this will be fired
      },
      cookPage: {
        show: 'setup'
      }
    },
    refs: {
      cookPage: 'cookpage',
      stepsPanel: 'stepspanel',
    }
  },

  launch: function() {
    this.current = 0;
    this.last = 0;
  },

  setup: function() {
    var sp = this.getStepsPanel();    
    sp.select(this.current);
  },

  stepSwipe: function(dataview, event, node, options, eOpts) {
    this.last = this.current;

    if (event.direction == 'up') {
      if (this.current < dataview.getStore().data.length-1) {
        this.current += 1;
      }
    } else if (event.direction == 'down') {
      if (this.current > 0) { this.current -= 1; }
    }

    // Select the current step. It will trigger the dataView's select
    // event which will end up calling goToStep.
    dataview.select(this.current);
  },

  goToStep: function(dataview, record) {
    dataview.scrollToSelected();
  }
});


Ext.define('NC.view.cook.Steps', {
  extend: 'Ext.DataView',
  id: 'steps',
  xtype: 'stepspanel',

  config: {
    flex: 1,
    activeItem: 1,
    itemTpl: '{text}',
    selectedCls: 'current',
    itemCls: 'step',
    scrollable: true,
    zIndex: 10,
    listeners: {
      // this is if the user doesn't swipe but directly selects one of the steps
      select: function(dataview, record, eOpts) { dataview.fireEvent('selectStep', dataview, record); }
    }
  },

  initialize: function() {
    // set scrolling behaviours off without turning scrollable off
    this.getScrollable().getScroller().onDragStart = null;

    this.callParent();
    var that = this;
    this.element.on('swipe', function(event, node, options, eOpts) {
      that.fireEvent('swipe', that, event, node, options, eOpts);
    });
  },

  scrollToSelected: function() {    
    //var toTop = Ext.get(this.element).down(".current").getY();
    var thisEl = Ext.get(this.element);
    var current = thisEl.down(".current");
    var prev = current;
    var y = 0;

    do {
      prev = prev.prev('.step');
      if (prev) { y += prev.getHeight(); }
    }
    while(prev);

    y = y - ((thisEl.getHeight()-current.getHeight())/3) + 5000;

    var scroller = this.getScrollable().getScroller();
    scroller.refresh();
    scroller.scrollTo(0, y, false);
  }
})

Edit 2:

Given the suggestion of “a timing issue,” I wrapped the select() in the setup function with a timer, like so:

setTimeout(function() { sp.select(0); }, 10);

Seems to be working now!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:37:34+00:00Added an answer on June 4, 2026 at 5:37 am

    Given the suggestion of “a timing issue” by rdougan, I wrapped the select() in the setup function with a timer, like so:

    setTimeout(function() { sp.select(0); }, 10);
    

    It works now, but I don’t know how robust it will be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.