Results 1 to 5 of 5

Thread: How to remove duplicate data Item in list?

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    26

    Default How to remove duplicate data Item in list?

    Hi All,

    I am populating list using xTemplate and a store with Json data.

    My Json file looks like

    [
    { 'name':'abc',
    id:1
    },
    {
    'name':cbd',
    id:2
    },
    {
    'name':'abc',
    id:31
    }
    ]

    I want populate list only with name property.
    My list should only

    abc
    cbd

    as abc is listed twice.

    How can i remove duplicates.??

    Thanks

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Check out the collect method on the Store
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    26

    Default

    Thanks Mitchell.

    Yes When i used Collect it returned array of objects.

    I have a very long list.

    I am using
    Code:
    {
    xtype:'list',
    store:myStore,
    itemTpl:'{ADVR_NM}'
    }
    to populate store whether same can be used.

    I tried

    Code:
    var array= advrStore.collect('ADVR_NM');
     console.log(array);
    It returned me array of objects.

    It will be useful how to consume this array in itemTpl.


    This question may sound easy, as I am a new learner Pls provide me a solution.

    Thanks so much

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Posts
    26

    Default

    Code:
    for(var i=0; i<array.length; i++){
                            console.log(array[i]);
                        }
    Using for loop I can able to traverse the array

    Can i use this same login in xtemplate and refer in itemTPl??

    will it work?

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    26

    Default help pls

    Any one can help me reg this ???????????????????????????

Posting Permissions

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