1. #11
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
    koolll is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    The reason this is important is the pull refresh plugin searches to find an existing record to match the new response. If it doesn't find a match it will add that data to the store creating a new record which is why you see duplicates. If you return an id in your response (idProperty = 'id') then the pull refresh plugin will be able to find the records and just update the record and therefore not having duplicates.
    Ok . let say my response return json format "idProperty = 'id'" . So sencha touch will detect the ID and update without duplicate record?

  2. #12
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Answers
    3451
    Vote Rating
    817
    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


    Yes... say you have something like:

    Code:
    [
        {
            "id" : 1,
            "foo" : "bar"
        },
        {
            "id" : 2,
            "foo" : "blah"
        }
    ]
    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. #13
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
    koolll is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Yes... say you have something like:

    Code:
    [
        {
            "id" : 1,
            "foo" : "bar"
        },
        {
            "id" : 2,
            "foo" : "blah"
        }
    ]
    Hi i try add the idProperty at my model.Please c the code below
    Code:
    Ext.define('bluebutton.model.BlueButton.TransactionList', {    extend: 'Ext.data.Model',
        config: {
            idProperty: 'transactionId',
            fields: [
    
    
                
                {  name: 'merchant_bbID'  },
                {  name: 'sessionId'  },
                {  name: 'deviceId'  },
                {  name :'transactionId'},
                {  name: 'createDateTime' },
                {  name: 'fullName' },
                {  name: 'action' },
                {  name: 'updatedPoint' },
                {  name: 'createDate' },
                 {  name: 'status' },
                 {  name: 'refresh' },
                
    
    
    
    
                
    
    
    
    
            ],
    
    
            proxy: {
                type: 'rest',
               
               url: 'http://192.168.251.131:8080/WebCommon/rest/BBWebService/getPointTransactionList',
    //            url: 'http://mixsoloffice.no-ip.biz:82/WebCommon/rest/BBWebService/getPointTransactionList',
                actionMethods: {
                    create: 'POST',
                    read: 'GET',
                    update: 'PUT',
                    destroy: 'DELETE'
                },
                        
                        
                          noCache: false, // get rid of the '_dc' url parameter
                        
                        extraParams: {
                            sessionId: "1",
                            deviceId: "1",
                            merchant_bbID: "merchant1",
    
    
                        // add as many as you need
                    },
    
    
    
    
    
    
                reader: {
                    type: 'json',
                    rootProperty: 'pointTransHistoryList',
                     totalProperty: 'totalRecord',
                    successProperty: 'success'
                    
                },
    
    
                writer: {
                    type: 'json',
                  
                },
            }
    
    
    
    
    
    
        }
    
    
    });
    transactionStore.js
    Code:
    
    
    Ext.define('bluebutton.store.BlueButton.TransactionList', {
        extend: 'Ext.data.Store',
           requires: [
                  'bluebutton.model.BlueButton.TransactionList'
        ],
    
    
        config: {
            grouper: {
                groupFn: function (record) {
                    return record.get('createDateTime');
                }
            },
    
    
              
    
    
                model: 'bluebutton.model.BlueButton.TransactionList',
                pageSize: 5,
                autoLoad: true,
                storeId: 'transactionlist',
                sorters: 'createDateTime',
                groupDir: 'DESC',
    
    
                clearOnPageLoad: false,  // This is true by default
                
    
    
    
    
        }
    });

    TransactionList.js
    Code:
    Ext.define('bluebutton.view.BlueButton.TransactionList', {    extend: 'Ext.List',
        xtype: 'transactionlistcard',
        id :'transactionlistcard',
        requires: [
            'Ext.field.Select',
            'Ext.field.Search',
          
            'Ext.plugin.ListPaging',
            'Ext.plugin.PullRefresh',
    
    
            'bluebutton.store.BlueButton.TransactionList',
            'bluebutton.view.BlueButton.TransactionListDetail',
    
    
        ],
        config: {
              styleHtmlContent: true,
            scrollable: 'vertical',
            itemHeight :20,
            variableHeights : false,
            store : { xclass : 'bluebutton.store.BlueButton.TransactionList'},
           grouped: true,
            indexBar: true,
              id :'transactionlist',
                masked: {
                    xtype: 'loadmask',
                    message: 'loading...'
                }, // masked
           plugins: [
                          
                                { xclass: 'Ext.plugin.PullRefresh'
    
    
                        
                                },
    
    
                              { 
                                   xclass: 'Ext.plugin.ListPaging',
    //                                 autoPaging: true,
                                  
                                     
                            
                            },
                    ],
    
    
            
            
            emptyText: '<p class="no-search-results">No Transaction record found matching that search</p>',
            itemTpl: Ext.create(
               'Ext.XTemplate',
                '<div class="tweet-wrapper">',
                    '<table>',
                        '<tr>',
                            '<td rowspan="2" width="28%" >',
    //                        '<div style="padding-left: 30px;">',
    //                        '   <img src="{imgUrl}" width="140" height="130" /></div>',
                            '</td>',
                            '<td>',
                            '   <div class="tweet">',
                            
                            '       <h3>Transaction ID: {transactionId} , Point: {updatedPoint} pts , Action: {action}</h3>',
                            '       <h3>Status: {status}, Transaction By: {fullName} , Transaction Date: {createDateTime}</h3>',
                           
                            '   </div>',
                            '</td>',
                        '</tr>',
                    '</table>',
                '</div>'
    
    
    
    
    
    
            ),
    
    
           
    
    
        },
        
    
    
    });
    Json result
    Code:
    
    {"success":true,"pointTransHistoryList":[{"transactionId":"162","createDate":"08\/03\/2013","createDateTime":"2013-03-08 13:01:01.101","fullName":"Ivor Kee Aik Hau","action":"add","updatedPoint":"44.00","status":"Success"},{"transactionId":"161","createDate":"07\/03\/2013","createDateTime":"2013-03-07 20:00:04.456","fullName":"Ivor Kee Aik Hau","action":"deduct","updatedPoint":"5.00","status":"Success"},{"transactionId":"160","createDate":"07\/03\/2013","createDateTime":"2013-03-07 20:00:03.345","fullName":"Ivor Kee Aik Hau","action":"deduct","updatedPoint":"4.00","status":"Success"},{"transactionId":"159","createDate":"07\/03\/2013","createDateTime":"2013-03-07 20:00:02.234","fullName":"Ivor Kee Aik Hau","action":"deduct","updatedPoint":"3.00","status":"Success"},{"transactionId":"158","createDate":"07\/03\/2013","createDateTime":"2013-03-07 20:00:01.123","fullName":"Ivor Kee Aik Hau","action":"deduct","updatedPoint":"2.00","status":"Success"}],"totalRecord":11}
    
    The duplicate issues solve. But I not able to update latest record. For eg :updatedPoint. I sure my java server return me latest updatedPoint result when I pull refresh

Thread Participants: 1

Tags for this Thread