Results 1 to 2 of 2

Thread: ListPaging for Local data Sqlite or Data array

  1. #1
    Sencha User
    Join Date
    Sep 2013
    Location
    Chennai, India
    Posts
    6
    Vote Rating
    0
      0  

    Default ListPaging for Local data Sqlite or Data array

    ListPaging plugin is extended to work with local data like SQLite or data array. The "nextPageCallback" is the main callback config in the extended plugin has to be implemented. This function will be called in loadpage of list's store. This function has three params,
    1. pageSize - which is defined it the store
    2. Page - the pages record that has to be returned
    3. callback2 (data, totalCount) data: the data returned for that page and totalCount: Total records to be paged.

    The nextPageCallback has to implement the following query in SQLite (in case of SQLite)
    1. To fetch the records for the requested page
    2. fetch the totalcount of records for the same criteria.

    The demo is available in this fiddle https://fiddle.sencha.com/#fiddle/1ik9
    PHP Code:
    Ext.define('Ext.ux.plugin.ListPagingLocal', {
        
    extend'Ext.plugin.ListPaging',
        
    alias'plugin.listpaginglocal',
        
    config:{
            
    nextPageCallback:null
        
    },
        
    bindStore:function(newStoreoldStore){
            
    this.callParent(arguments);
            var 
    me this,
                
    store this.getList().getStore(),
                
    total store.getTotalCount();
            if (
    newStore){
                
    newStore.loadPage = function(pageoptionsscope) {
                    var 
    callback me.getNextPageCallback(),
                        
    pageSize store.getPageSize();
                    
    debugger;
                    if (
    callback){
                        
    callback(pageSize,page,
                            function(
    data,totalCount,sorter){ //callback2 
                                
    if (!page || page<=1){
                                    
    store.removeAll();
                                    if (
    sorter){
                                        
    store.setSorters([sorter]);
                                    }else{
                                        
    store.setSorters([]);
                                    }
                                }
                                
    store.setTotalCount(totalCount);
                                
    store.currentPage page;
                                
    store.addData(data);
                                
    store.fireEvent('load'store); 
                            }
                        );
                    }
                }
            }
        }
    }); 

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Vote Rating
    296
      0  

    Default

    Nice job. Thanks for sharing your work with the community!

Similar Threads

  1. Replies: 8
    Last Post: 12 Jul 2017, 7:35 AM
  2. How to create xml file in sencha by reading data from Sqlite data base tables
    By Sameer Khan in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 29 Dec 2011, 11:23 AM
  3. No data displaying in Ext JS local array Datagrid
    By wavedan in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 6 Aug 2010, 1:18 AM

Posting Permissions

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