1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
    franveragg is on a distinguished road

      0  

    Default Scrolling to a text in the html of a panel

    Scrolling to a text in the html of a panel


    Hi!
    I have a panel with about 2800 characters in the html property where I searchfor a user defined string.
    I want to make the panel scroll to the section where the string is found.
    I know you can scroll like this:


    myPanel.getScrollable().getScroller().scrollTo(0, stringY);

    My problem is getting the second parameter, the Y position where the string was found.
    I have tried to surround the found string with an HTML element, catching it with Ext.get and document.getElementByID and used all the offsets, top and getY methods of both plain JavaScript and Ext.dom.element to try to get the Y position without any success.
    Any ideas?
    Thanks in advance!

  2. #2
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
    franveragg is on a distinguished road

      0  

    Default


    anyone?

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
    franveragg is on a distinguished road

      0  

    Default


    Solved it!
    I guess I was too tired yesterday because after trying the same thing today it worked!
    Solution:
    wrap the text with an id: <b id="result">result</b>
    scroll to the text like this:
    content.getScrollable().getScroller().scrollTo(0,document.getElementById('result').offsetTop,false);

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    Nice. You should be also able to use Ext.get('result') instead of document.getElementById('result')
    Sencha Touch 2.x
    Ext.ux.MultiBadgeButton - Forum | GitHub
    Ext.field.SmallRadio - Forum | GitHub

    Ext JS 4.x
    Ext Calendar Pro - Time Indicator - Forum| GitHub

  5. #5
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
    franveragg is on a distinguished road

      0  

    Default


    Quote Originally Posted by jerome76 View Post
    Nice. You should be also able to use Ext.get('result') instead of document.getElementById('result')
    You are right Jerome! Thanks!
    Updated code:
    Code:
    content.getScrollable().getScroller().scrollTo(0,Ext.get('result').offsetTop,false);

Thread Participants: 1

Tags for this Thread