1. #11
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,160
    Vote Rating
    674
    Answers
    474
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Another way to do it without filter:

    Code:
    Ext.select('a').each(function(el){
        if(el.dom.hostName != location.hostName){
            el.addClass('external');
        }
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  2. #12
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Answers
    13
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    In its current form where it filters using a string selector as the parameter, or will it be upgraded to accept a selection function in addition?

  3. #13
    Sencha User
    Join Date
    Aug 2009
    Posts
    41
    Vote Rating
    0
    Dig4Fire is on a distinguished road

      0  

    Default


    What about this jQuery-Code?
    PHP Code:
    $('td:contains(Henry)').nextAll().andSelf().addClass('highlight'); 
    Highlight all of the cells following the one containing Henry (include the one that contains Henry)

  4. #14
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Answers
    13
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Are you porting something to Ext Core?

  5. #15
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,160
    Vote Rating
    674
    Answers
    474
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Something like:

    Code:
    var el = Ext.select('td:contains(Henry)').item(0);
    while(el){
        el = el.addClass('highlight').next();
    }
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #16
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Answers
    13
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    I'm thinking about the possiblity of an override statement which adds come of these obscure capabilities. Pretty easy to add them. CompositeElement just encapsulates a set of DOM elements.

  7. #17
    Sencha User
    Join Date
    Aug 2009
    Posts
    41
    Vote Rating
    0
    Dig4Fire is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal View Post
    Are you porting something to Ext Core?
    No, only compare the libraries. Not sure which one I should use. (Sorry for my bad english)

  8. #18
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Answers
    13
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Like this:

    Code:
    Ext.override(Ext.CompositeElementLite, {
    
    //  need this until next release - pulled in from full Ext
        fill : function(els){
            var me = this;
    
    //      Keep reference to last version of self before refill
            me.prevObject = new me.constructor(me.elements);
    
            me.elements = [];
            me.add(els);
            return me;
        },
    
        nextAll: function() {
            var els = this.elements, i, l = els.length, n, r = [], ri = -1;
            for (i = 0; i < l; i++) {
                for (n = els[i].nextSibling; n; n = n.nextSibling) {
                    r[++ri] = n;
                }
            }
            this.fill(r);
            return this;
        },
    
        andSelf: function() {
            if (this.prevObject) {
                this.add(this.prevObject.elements); // add takes an Array. Should it take another Composite???
            }
            return this;
        }
    });
    Then you would use

    Code:
    Ext.select('td:contains(Altria)').nextAll().andSelf().addClass('x-grid3-dirty-cell');
    (As tested on the array-grid example in ExtJs examples as you can tell by the data)

  9. #19
    Sencha User
    Join Date
    Aug 2009
    Posts
    41
    Vote Rating
    0
    Dig4Fire is on a distinguished road

      0  

    Default


    Instructive code, thx

  10. #20
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,160
    Vote Rating
    674
    Answers
    474
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    A filter method that accepts a function would be good. I'm playing around with some code now:

    Code:
    Ext.onReady(function(){
        for(var i = 0; i < 10; ++i){
            Ext.getBody().createChild({
                tag: 'div',
                cls: i % 2 == 0 ? 'foo' : 'bar'
            });
        }
        console.log(Ext.select('div').filter('.foo').getCount());
        console.log(Ext.select('div').filter(function(el){
            return el.is('.foo');
        }).getCount());
    });
    Obvoiusly both return the same results.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!