gpt4 book ai didi

grid - EXTJS 5.0 : Infinite Grid scrolling not working with extraParams in store

转载 作者:行者123 更新时间:2023-12-01 01:16:45 29 4
gpt4 key购买 nike

我正在使用 ExtJS 5.0.1。我有一个不自动加载的网格。使用 TopBar 中的单击按钮手动加载商店后,网格将接收记录。我正在尝试在此网格上实现无限滚动。我的商店有额外的参数需要传递到后端才能获取记录。第一个页面加载完成后,对于第二个页面,没有额外的参数传递给后端。我该如何纠正这个问题?我的商店如下所示 ->

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
}
});
}

}
]
}
});

最佳答案

我通过添加

解决了这个问题
store.removeAll();
store.currentPage = 1;
store.getProxy().setExtraParam("fromDate", fromDay);
store.getProxy().setExtraParam("toDate", toDay);
store.load();

关于grid - EXTJS 5.0 : Infinite Grid scrolling not working with extraParams in store,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32971492/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com