Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

Hybrid View

  1. #1
    Sencha User yuryn1961's Avatar
    Join Date
    Nov 2011
    Posts
    6
    Vote Rating
    0
    yuryn1961 is on a distinguished road

      0  

    Default Unanswered: Select from array, is it possible?

    Unanswered: Select from array, is it possible?


    Hi,

    I've got a javascript array:

    var x = [
    {id:22, name:'Merry'},
    {id:26, name:'Poppins'},
    {id:345, name:'Popcorn'}
    ];

    Is it possible to create with Sencha Core a method which returns a sub array by a given param, like SQL command (select elements where name like '%Pop%').

    function x(x, 'Pop') { } will returns:
    [
    {id:26, name:'Poppins'},
    {id:345, name:'Popcorn'}
    }.
    Any help will be appreciate.
    Thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,519
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can use RegEx but you need something to look at the object. We have one for an array of strings.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    414
    Answers
    41
    Vote Rating
    60
    burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough

      0  

    Default


    What you're looking for, I think, is the function Ext.Array.filter which can be used like so:

    Code:
    var pops = Ext.Array.filter(array, function(item) {
        return item.name.indexOf('Pop') != -1;
    });

  4. #4
    Sencha User yuryn1961's Avatar
    Join Date
    Nov 2011
    Posts
    6
    Vote Rating
    0
    yuryn1961 is on a distinguished road

      0  

    Default


    Thanks burnnat, I tried it, it does not work with Ext Core (as the LesJ's solution), but your reply helped me.
    Here is my code:
    function selectFromArray(arr, s){
    var result=new Array();
    Ext.each(arr, function(item){
    if(item.name.indexOf(s) > -1){
    result.push(item);
    }
    });
    return result;
    }

    Thanks to all again

  5. #5
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,289
    Answers
    12
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    You can also take a look at the MixedCollection class, which is a beefed up Array.

    See how you can filter data in stores:

    http://docs.sencha.com/ext-js/4-0/#!...-method-filter