Results 1 to 6 of 6

Thread: Determine if node is visible?

  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
      0  

    Default Determine if node is visible?

    There doesn't seem to be any built in method of determining if a node is visible. The reason this is handy, is that a node of interest could be many deep, and even though it's parent, may be expanded, this does not mean the node is necessarily visible. So checking if the parentNode of a particular node is expanded does not guarantee that a child node is visible.

    Is there any way to do this?

  2. #2
    Ext JS Premium Member gevik's Avatar
    Join Date
    May 2009
    Location
    The Netharlands
    Posts
    277
    Vote Rating
    37
      0  

    Default

    I don't think there is a way to see whether a node is visible but if you have a reference to a given node, then you can call the ensureVisible() method to force that node being visible.

    I hope this helps.

  3. #3
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
      0  

    Default

    Unfortunately that won't help me in this situation. I don't want to make it visible, I need to know if it is visible, and if not, do something based on that.

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890
    Vote Rating
    90
      0  

    Default

    Node? Surely you mean Component?

    You mean a Component may be in a card of a card layout which is hidden.

    I use this

    Code:
    Ext.override(Ext.Component, {
        ensureVisible: function(stopAt) {
            var p;
            this.ownerCt.bubble(function(c) {
                if (p = c.ownerCt) {
                    if (p instanceof Ext.TabPanel) {
                        p.setActiveTab(c);
                    } else if (p.layout.setActiveItem) {
                        p.layout.setActiveItem(c);
                    }
                }
                return (c !== stopAt);
            });
            this.el.scrollIntoView(this.el.up(':scrollable'));
            return this;
        }
    });
    With the pseudo:

    Code:
    Ext.DomQuery.pseudos.scrollable = function(c, t) {
        var r = [], ri = -1;
        for(var i = 0, ci; ci = c[i]; i++){
            var o = ci.style.overflow;
            if(o=='auto'||o=='scroll') {
                if (ci.scrollHeight < Ext.fly(ci).getHeight(true)) r[++ri] = ci;
            }
        }
        return r;
    };

  5. #5
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
      0  

    Default

    I mean node, as in TreeNode.

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890
    Vote Rating
    90
      0  

    Default

    So if any of its ancestor nodes are collapsed, it's not visible.

    Then, if it is in fact present as part of an expanded parent, use Element.getOffsetsTo to find out if it's out of the visible region of the TreePanel's body.

    It's all just basic progging.

Similar Threads

  1. How to determine if an HtmlEditor is empty?
    By dbassett74 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 27 Jun 2009, 10:57 AM
  2. How to determine that a component is rendered?
    By sksoft in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 13 Feb 2009, 4:07 AM
  3. How can i determine the number of visible rows in a table?
    By Kango_V in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 6 Aug 2008, 5:11 AM
  4. How to check if a Node is visible
    By thomas.de in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 30 Nov 2007, 9:08 AM

Posting Permissions

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