2015-10-06 82 views
3

我正在使用ExtJS 5.0.1。我有一个不自动加载的网格。一旦通过使用TopBar中的单击按钮手动加载商店,网格就会收到记录。 我想在这个网格上实现无限滚动。我的商店有额外的参数需要传递给后端以获取记录。第一页加载后,对于第二页,没有额外的参数传递给后端。我该如何解决这个问题? 我的店看起来如下 - >EXTJS 5.0:无限网格滚动无法在store中使用extraParams

Ext.define('MyStore', { 
    // extend: 'Ext.data.BufferedStore', 
    extend: 'Ext.data.Store', 
    model : 'MyModel', 

    remoteSort: true, 
    buffered: true, 
    leadingBufferZone: 10, 
    trailingBufferZone: 10, 
    pageSize: 100, 

    proxy: { 
    type : 'rest', 
    format: 'json', 
    url : '/myApp/list', 
    extraParams: { 
     fromDate: '', 
     toDate: '' 
    }, 
    reader: { 
     type: 'json', 
     rootProperty: 'data', 
     totalProperty: 'totalCount' 
    } 
    } 
}); 

我的网格看起来如下 - >

Ext.define('MyGridl', { 
    extend: 'Ext.grid.Panel', 
    requires: [ 
    'MyStore' 
    ], 
    layout: 'fit', 
    loadMask: true, 
    viewConfig: { 
     preserveScrollOnRefresh: true 
    },   
    initComponent: function() { 
    this.id = 'myGrid'; 
    this.store = new MyStore(); 
    this.callParent(arguments); 
}, 
overflowY: 'auto', 
frame: true, 
columns: [{ 
    xtype: 'rownumberer', 
    width: 50, 
    sortable: false 
},{ 
    text: 'Column1', 
    dataIndex: 'Col1', 
    flex: 1 
},{ 
    text: 'Column2', 
    dataIndex: 'Col2', 
    flex: 1 
} 
], 
plugins: [ 
{ 
    ptype: 'bufferedrenderer', 
    trailingBufferZone: 10, 
    leadingBufferZone: 10, 
    scrollToLoadBuffer: 10 
} 
], 
tbar: { 
    items: [{ 
     xtype  : 'datefield', 
     id   : 'fromDate', 
     emptyText: 'Enter From Date', 
     listeners : { 
      render : function(datefield) { 
       datefield.setValue(Ext.Date.add(new Date(), Ext.Date.DAY, -5)); 
      } 
     } 
    },{ 
     xtype  : 'datefield', 
     id   : 'toDate', 
     emptyText: 'Enter To Date', 
     listeners : { 
      render : function(datefield) { 
       datefield.setValue(new Date()); 
      } 
     } 
    },{ 
     xtype: 'button', 
     text: 'Filter by Date',          
     style: { 
      marginLeft: '15px' 
     }, 
     scope: this, 
     handler: function(me){  
      var store = Ext.getStore('myStore'), 
      fromDay = me.up().down('#fromDate').getValue(), 
      toDay = me.up().down('#toDate').getValue(); 

      store.removeAll(); 
      store.load({ 
       params:{ 
        fromDate: fromDay, 
        toDate: toDay 
       } 
      }); 
     }     

    }      
    ] 
} 
}); 
+0

添加在后端总数解决修复了这个问题我的问题是加载更多记录。但是当第二页加载时,我无法将额外的参数发送到后端。我该如何解决这个问题? – KavitaC

回答

2

我加入

store.removeAll(); 
        store.currentPage = 1; 
        store.getProxy().setExtraParam("fromDate", fromDay); 
        store.getProxy().setExtraParam("toDate", toDay); 
        store.load();