Page 1 of 2 12 LastLast
Results 1 to 10 of 13

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

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Kind of suspect of why you would need that param, shouldn't you just return what the client asks for?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    This is because you aren't using id in your response.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      0  

    Default

    what u means id? can give me some example?

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Your response, each of the data for each model instance should have a unique id.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      0  

    Default

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

  8. #8
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    No, your response should return ids for each data.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  9. #9
    Sencha User
    Join Date
    Nov 2012
    Posts
    84
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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