Results 1 to 6 of 6

Thread: Scroll Event on Ext Component

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default Scroll Event on Ext Component

    Hello,

    Let me tell you first I am very new to Ext4Js. I am using a Ext.Component as my west navigation. Inside that I have a custom tree and the tree loads data based on the dynamic scroll -i.e more the user scrolls down more items gets added to the tree. The tree is using knockout.js fundamentals. I need to get the scroll event of the Ext.Component - so that when the user scrolls down, the event gets fired.

    The code I have is :

    Code:
    Ext.QuickTips.init();
                var viewport = Ext.create('Ext.Viewport', {
                    id: 'border-example',
                    layout: 'border',
                    items: [
                    // create instance immediately
                Ext.create('Ext.Component', {
                    region: 'north',
                    height: 60, // give north and south regions a height
                    contentEl: 'ui-layout-north'
    
    
                }),
                                {
                                    // lazily created panel (xtype:'panel' is default)
                                    region: 'south',
                                    contentEl: 'ui-layout-south',
                                    split: true,
                                    height: 100,
                                    minSize: 100,
                                    maxSize: 200,
                                    collapsible: true,
                                    collapsed: true,
                                    title: 'South',
                                    margins: '0 0 0 0'
                                },
                {
                    region: 'west',
                    stateId: 'navigation-panel',
                    id: 'west-panel', // see Ext.getCmp() below
                    title: 'West',
                    split: true,
                    width: 200,
                    minWidth: 175,
                    maxWidth: 400,
                    collapsible: true,
                    animCollapse: true,
                    collapsed: true,
                    collapseMode: 'mini',
                    autoScroll: true,
                    margins: '0 0 0 5',
                    layout: 'accordion',
                    items: [{
                        contentEl: 'ui-layout-west',
                        title: 'Navigation',
                        autoScroll: true,
                        listeners: {
                            scroll: function (e, t, eOpts) {
                                Ext.Msg.alert('Scrolled !!!');
                            }
                        }
    I don't know why the scroll event is not getting fired. Could anyone please guide.

    Regards,
    Anirban
    Last edited by scottmartin; 21 Jun 2012 at 9:40 AM. Reason: Format your code!

  2. #2
    Sencha User grgur's Avatar
    Join Date
    Aug 2007
    Location
    Split, Croatia
    Posts
    155
    Answers
    10
    Vote Rating
    27
      1  

    Default

    Change the listeners part to:

    Code:
        listeners: {
                 scroll: {
                          element: 'el',
                          fn: function(){ console.log('scrolling', arguments); }
    	     }
        }
    Binding listeners is two-fold -> you either listen at the component level (component-related events, as in docs) or dom elements. We need the latter in this case, thus we bind the scroll event to the element, referenced by 'el'

    Good luck
    <div style="float: left; width: 70px;">http://appac.us/mcs.png</div><div style="float: left; height: 100px;">Grgur Grisogono
    Ext JS in Action SE co-author
    Exercising awesomeness at Modus Create - Official Sencha Partner

    Get in touch for Sencha Touch Training
    @ggrgur</div><div style="clear:both;"></div>

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Thanks for your response. But this does not work. The Ext.Component is getting associated with the element "ui-layout-west"

    I have 3 divs inside it. I have attached with all divs[just to see if the scroll gets fired or not] that are there, but still no scroll event gets fired.

    items: [{
    contentEl: 'ui-layout-west',
    title: 'Navigation',
    autoScroll: true,
    listeners: {
    scroll: {
    element: 'ui-layout-west',
    fn: function () { Ext.Msg.alert('Scrolled !!!');}
    },
    scroll: {
    element: 'dmcontent',
    fn: function () { Ext.Msg.alert('Scrolled !!!');}
    },
    scroll: {
    element: 'DataManager',
    fn: function () { Ext.Msg.alert('Scrolled !!!');}
    }
    }
    }, {
    title: 'Settings',
    html: '<p>Some settings in here.</p>'
    }, {
    title: 'Information',
    html: '<p>Some info in here.</p>'
    }]

    Thanks,
    Anirban

  4. #4
    Sencha User grgur's Avatar
    Join Date
    Aug 2007
    Location
    Split, Croatia
    Posts
    155
    Answers
    10
    Vote Rating
    27
      0  

    Default

    Try to use the exact code I posted, no need to change anything (even the 'el' string). I've tested and it works. Let me know either way
    <div style="float: left; width: 70px;">http://appac.us/mcs.png</div><div style="float: left; height: 100px;">Grgur Grisogono
    Ext JS in Action SE co-author
    Exercising awesomeness at Modus Create - Official Sencha Partner

    Get in touch for Sencha Touch Training
    @ggrgur</div><div style="clear:both;"></div>

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,891
    Answers
    41
    Vote Rating
    89
      0  

    Default

    advah, please do not hijack other people's threads. It makes answering difficult.

    anirbankundu, the scroll listener you add will be added to the main element of the west component. Not the contentEl.

    But I'm wondering why you are using contentEl.

    You just have some static HTML in your page to display in every region? Doesn't seem much point in using ExtJS!

  6. #6
    Sencha Premium Member
    Join Date
    Mar 2013
    Location
    Sydney
    Posts
    12
    Vote Rating
    2
      0  

    Default

    Thanks grgur. It works well.As soon as I moved the listener into controller it stopped working. Because scroll is not component related event is there a way to add dom event handler in controller?Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •