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

      0  

    Default Unanswered: sencha touch~Reset extra param when load more event fire

    Unanswered: sencha touch~Reset extra param when load more event fire


    I need to reassign extra param when load more even fire. But I dont have any idea

    Here is my code
    List.js
    Code:
    Ext.define('bluebutton.view.BlueButton.TestingList', {        extend: 'Ext.List',
            xtype: 'testinglistcard',
            requires: [
                'Ext.field.Select',
                'Ext.field.Search',
        //        'bluebutton.view.BlueButton.MemberDetail',
                 'Ext.plugin.ListPaging',
                'Ext.plugin.PullRefresh',
                'Ext.dataview.Override'
        
            ],
            config: {
              
        
                styleHtmlContent: true,
                scrollable: 'vertical',
                indexBar: true,
                singleSelect: true,
                onItemDisclosure: true,
                grouped: true,
                variableHeights : false,
                  store : { xclass : 'bluebutton.store.BlueButton.Testing'},
                    itemHeight :100,
                loadingText : 'loading',
                id :'testinglist',
                  
                           
                               plugins: [
                              
                                    { xclass: 'Ext.plugin.PullRefresh',
                                        refreshFn: function() {             
        
                                          
                                                var transaction = Ext.ModelMgr.getModel('bluebutton.model.BlueButton.Testing');
                                                var proxy  = transaction.getProxy();
                                                 proxy.setExtraParam('refresh', 'true' );
             
                                                    Ext.getStore('testingstore').load();
        
                                            },
                            
                                    },
        
                                  { 
                                       xclass: 'Ext.plugin.ListPaging',
                                         autoPaging: true,
                                          loadNextPage: function() {
        
                                           var transaction = Ext.ModelMgr.getModel('bluebutton.model.BlueButton.Testing');
                                                var proxy  = transaction.getProxy();
                                                 proxy.setExtraParam('refresh',  );
             
                                                    Ext.getStore('testingstore').load();
        
        
                                         }
                                
                                },
                        ],
                      
        
        
                 masked: {
                        xtype: 'loadmask',
                        message: 'loading...'
                    }, // masked
        
                emptyText: '<p class="no-search-results">No member record found matching that search</p>',
                itemTpl: Ext.create(
                    'Ext.XTemplate',
                    '<div class="tweet-wrapper">',
                        '<table>',
                            '<tr>',
        
                                '<td>',
                                '   <div class="tweet">',
                                '       <h3>{invoiceId}</h3>',
                                '      <h3>Name: {billNumber}</h3>',
                                '       <h3>Point Avalaible : {invoiceDate} , Last Visited : {invoiceAmount}</h3>',
                                
                                '   </div>',
                                '</td>',
                            '</tr>',
                        '</table>',
                    '</div>'
        
        
                ),
        
               
        
            },
            
        
        });
    Store.js
    Code:
            Ext.define('bluebutton.store.BlueButton.Testing', {
            extend: "Ext.data.Store",
            requires: ['bluebutton.model.BlueButton.Testing'],
            config: {
              
              grouper: {
                    groupFn: function (record) {
                        return record.get('invoiceId')[0];
                    }
                },
                 model :'bluebutton.model.BlueButton.Testing',
              storeId :'testingstore',
                autoLoad: true,
                  pageSize: 5,
                    clearOnPageLoad: false, 
                   
            }
        });
    Model.js
    Code:
     Ext.define('bluebutton.model.BlueButton.Testing', {        extend: 'Ext.data.Model',
            config: {
            
                idProperty: 'testingModel',
                fields: [
                    {  name :'invoiceId'},
                    {  name: 'billNumber' },
                    {  name: 'invoiceDate' },
                    {  name: 'invoiceAmount' },
                    {  name :'downloadLink'},
                    {  name: 'refresh' },
        
        
        
                ],
        
                proxy: {
                    type: 'rest',
                   url: 'http://192.168.251.108:8080/RESTFulExample/rest/json/metallica/invoicejsonPost',
                    reader: 'json',
                    actionMethods: {
                        create: 'POST',
                        read: 'GET',
                        update: 'PUT',
                        destroy: 'DELETE'
                    },
                            
                      
                        noCache: false, // get rid of the '_dc' url parameter
                            
        //                    extraParams: {
        //                    userid: "test",
        //                    // add as many as you need
        //                },
        
        
        
        
                    reader: {
                        type: 'json',
                        rootProperty: 'invoice'
                    },
        
                    writer: {
                        type: 'json',
                      
                    },
                }
        
        
        
            }
        
        });
    I need to assign extra param "**refresh**" to true when i refresh the list. On the other hand, if the load more event fire i need to assign param **refresh** to false. Please give me solution. Thanks

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


    Kind of suspect of why you would need that param, shouldn't you just return what the client asks for?
    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 User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
    koolll is on a distinguished road

      0  

    Default


    Hi , I need to implement pull refresh and paging plugin. The auto paging I had done successfully. But the pull refresh got some bug. It will return duplicate result.
    But if I try coding below
    Code:
      { xclass: 'Ext.plugin.PullRefresh',  refreshFn: function() {             
         Ext.getStore('testingstore').load();
             },
                        
                                },
    It only will return the second page of the list. The reason is because the "start" and "limit" param only return the second page of the parameter.Do you had any example about the pull refresh and paging. I am using java

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Answers
    3470
    Vote Rating
    836
    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


    This is because you aren't using id in your response.
    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.

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

      0  

    Default


    what u means id? can give me some example?

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Answers
    3470
    Vote Rating
    836
    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


    Your response, each of the data for each model instance should have a unique 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.

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

      0  

    Default


    You means I should put ID in proxy?got example?

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Answers
    3470
    Vote Rating
    836
    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


    No, your response should return ids for each data.
    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.

  9. #9
    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
    No, your response should return ids for each data.
    Sorry, i am new for sencha touch. Ok , let say i response Ids for my data. Then what is the next step?Can you explain more detail. Thanks in advance

  10. #10
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Answers
    3470
    Vote Rating
    836
    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


    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.
    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.

Thread Participants: 1

Tags for this Thread