1. #1
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Vote Rating
    4
    squarefan is on a distinguished road

      0  

    Default PullRefresh duplicate items

    PullRefresh duplicate items


    Hi,

    I am experiencing a strange problem with the pull to refresh list plugin. When I load the data normally via store.load() it is cleared and loaded correctly. When I reload the store via the pull to refresh items are getting duplicated (previous ones are not getting cleard).

    I tried to add a listeners to the store (beforeload, load, updaterecord etc.) but all of these are not fired when using reloading via the store.

    here is my store config:
    Code:
            var store = new Ext.data.Store({
                model: 'Test',
                autoLoad: true,
                grouper: {groupFn: function(record) {
                      try { 
                        return record.get('last_name')[0].toUpperCase();
                      } catch(err) { }
                    }
                },
                proxy: {
                    type: 'scripttag',
                    autoAbort: true,
                    url: serverurl,
                    extraParams: {meta: true, 
                                 task: "test",                          
                                 timestamp: new Date().getTime() // if not passed values are cached ! only mobile
                    },
                    reader: {
                        type: 'json',
                        rootProperty: 'root'
                    }       
                }
            });
    I also tried adding the root: {} to the store as seen in a diffrent post as bug fix.. but that didn't help. As mentioned it only happens when reloaded via the pull-to-refresh action... normal .load(), reload() work as expected.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,652
    Vote Rating
    901
    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


    Do you have an idProperty set on the model? The records are matched by id.
    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
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Vote Rating
    4
    squarefan is on a distinguished road

      0  

    Default


    Hi, no I didn't.

    If I set an idProperty didn't fix the problem though.

    Code:
            Ext.define('Test', {extend: "Ext.data.Model", config: {
                 idProperty: 'test',
                fields: [
                    {name: 'tst1', type: 'int'},
                    {name: 'tst2', type: 'string'},
                    {name: 'tst3', type: 'string'},
                    {name: 'tst4', type: 'string'},
                    {name: 'tst5', type: 'int'},
                    {name: 'tst6', type: 'int'}
                ]}
            });

  4. #4
    Sencha User
    Join Date
    Apr 2010
    Posts
    1
    Vote Rating
    0
    virtualone is on a distinguished road

      0  

    Default


    @squarefan

    idProperty should point to unique record by which each model object can be differentiated ... check your field name

  5. #5
    Sencha User
    Join Date
    May 2012
    Posts
    8
    Vote Rating
    0
    swathi001 is on a distinguished road

      0  

    Default Pull and refresh adding new record with old record as well ..

    Pull and refresh adding new record with old record as well ..


    //Below is my list em binding data from web service call
    Code:
     {
                    xtype:'list',
                    id:'userReviewList',
                    plugins:[
                        {
                            xclass:'Ext.plugin.ListPaging',
                            autoPaging:true
                        }
                    ],
                    title:'User Review',
                    cls:'reviewList',
                    flex:1,
                    store:{
                        autoLoad:true,
                        id:'reviewStore',
                        idProperty: 'ReviewId',
                        clearOnPageLoad: false,
                        fields:['Comment', 'Rating', 'ReviewId', 'RatingUrl'],
                        proxy:{
                            type:'jsonp',
                            url:'http://url/PropertyService.svc/GetUserReviewDetails?projectId=1',
                            reader:{
                                type:'json',
                                rootProperty:'d'
                            }
                        }
                    },
    //In controller when user adds review to load list again em using below code
    Code:
      Ext.getStore('reviewStore').load();
    //But now i need to reload the list data by scrolling it when other user add the review comment. Even i am using idProperty which is unique to list. The list is refreshing new value with old values as well and list keep on loading so i need to load only updated record not with old data as well

  6. #6
    Sencha User
    Join Date
    Aug 2012
    Location
    Denmark
    Posts
    3
    Vote Rating
    1
    maresh2all is on a distinguished road

      1  

    Default


    I experienced the same thing so the fix that did the work for me was to declare my own refreshFn
    Code:
      plugins: [
                {
                    xclass: 'Ext.plugin.PullRefresh',
                    pullRefreshText: 'Pull down for fresh beer',
                    refreshFn: function() {             
                      console.log("Boom");
                      Ext.getStore('BeerStore').load();
                    },
                }
            ],
    It did the trick for me

    PS. this solution might be against the purpose of refresh. From what i understood the plugin doesn't do anything on the store.
    Quote Originally Posted by mitchellsimoens View Post
    The pull refresh plugin doesn't actually do anything on your store. It has it's own Ext.data.Operation load the data and then iterates through it. If a matching record is found in the store then it will update the data. If a match is not found it will add the record to the store." --mitchellsimoens
    i could use some clarification as well
    Last edited by maresh2all; 5 Oct 2012 at 7:58 AM. Reason: epiphany

  7. #7
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    24
    Vote Rating
    0
    pherris is on a distinguished road

      0  

    Default


    I ran across this thread and thought I'd post the solution. The idProperty is a pointer to the field in your model that contains the unique ID of your record set. Your configuration would look something like this:

    Code:
     Ext.define('Test', {
    extend: "Ext.data.Model", 
    config: {
                 idProperty: 'tst1', //note this maps to an actual field below
                fields: [
                    {name: 'tst1', type: 'int'},
                    {name: 'tst2', type: 'string'},
                    {name: 'tst3', type: 'string'},
                    {name: 'tst4', type: 'string'},
                    {name: 'tst5', type: 'int'},
                    {name: 'tst6', type: 'int'}
                ]}
            });
    Last edited by pherris; 1 Apr 2013 at 1:25 PM. Reason: code formatting was lost

  8. #8
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    523
    Vote Rating
    43
    BostonMerlin is a jewel in the rough BostonMerlin is a jewel in the rough BostonMerlin is a jewel in the rough

      1  

    Default


    Quote Originally Posted by squarefan View Post
    Hi, no I didn't.

    If I set an idProperty didn't fix the problem though.

    Code:
            Ext.define('Test', {extend: "Ext.data.Model", config: {
                 idProperty: 'test',
                fields: [
                    {name: 'tst1', type: 'int'},
                    {name: 'tst2', type: 'string'},
                    {name: 'tst3', type: 'string'},
                    {name: 'tst4', type: 'string'},
                    {name: 'tst5', type: 'int'},
                    {name: 'tst6', type: 'int'}
                ]}
            });
    Your idProperty should point to the field 'name', not a value in the field. In addition, every possible value inside your 'name field' should be unique. If it's possible that the name field could potentially include 'tst1' many times, don't use that field, find another or create a new field with a combination of values that would make that row unique.

    Hope that helps
    John

  9. #9
    Sencha User Craynay's Avatar
    Join Date
    Nov 2014
    Posts
    1
    Vote Rating
    0
    Craynay is on a distinguished road

      0  

    Default


    Quote Originally Posted by BostonMerlin View Post
    Your idProperty should point to the field 'name', not a value in the field. In addition, every possible value inside your 'name field' should be unique. If it's possible that the name field could potentially include 'tst1' many times, don't use that field, find another or create a new field with a combination of values that would make that row unique.

    Hope that helps
    John
    That worked for me! Thanks for the detailed explanation!