我有EXT JS 4.2网格并存储。
现在,一个页面加载网格从存储中获取数据并显示在UI上。
我在页面上有日期下拉过滤器。在选择日期过滤器的日期时,一个请求应该转到服务器从db获取数据并用更新的数据重新加载存储的情况,而网格应使用更新的存储值进行更新。
我的问题是我如何才能从网格负载中解除现有商店的绑定,设置具有日期的商店参数,然后获取商店中的新数据并绑定到网格。并在网格上显示更新的数据?
提前致谢
这是在其中创建网格的代码,在单击时需要创建一个按钮,需要将其传递给服务器
{
xtype: 'container',
layout: 'hbox',
style: 'margin-left: 152px;',
width: 960,
height: 'auto',
cls: 'portlet full',
items: Ext.getCmp('grid')
}, { //Create Button to fetch Grid Checked Data//
xtype: 'container',
layout: 'hbox',
style: 'margin-left: 163px;padding-top: 20px;padding-bottom: 59px;',
items: [
Ext.create('Ext.Button', {
name: 'Click me',
width:'40px',
handler: function() {
更新===========================================
Ext.create('store', {storeId: 'storetest2'}).load({
params: {
// To send Extra Params
'lastname':'test2'
},
callback: function(records, operation, success) {
// To Perform some call back operations
}
});
scndStore = Ext.data.StoreManager.lookup('storetest2'),
Ext.getCmp('grid').reconfigure(scndStore);
更新===========================================
})
],
最佳答案
将数据放入新商店后,您可以使用
grid.reconfigure(store, [columns])
更改绑定到网格的商店。.请查看docs。
一个简单的工作fiddle
更新:试试这个
var store2 = Ext.create('Ext.data.Store', {
model : 'store2Model', //Don't miss to mention model
storeId: 'storetest2',
proxy : {
type : 'ajax',
url :'someUrl'
reader : {
type : 'json',
root : 'items' // depends
}
}
});
store2.load({
params: {
// To send Extra Params
'lastname':'test2'
},
callback: function(records, operation, success) {
grid = Ext.getCmp('grid'); //First check whether you are getting this comp properly
grid.reconfigure(store2);
}
});