我有 EXT JS 4.2 Grid 和存储。
现在一个页面加载网格从存储中获取数据并显示在 UI 上。
我在页面上有日期下拉过滤器。在日期过滤器的日期选择上,一个请求应该转到服务器从数据库中获取数据并使用更新的数据重新加载存储,并且网格应该使用更新的存储值进行更新。
我的问题是如何解除现有商店与网格加载的绑定(bind),设置带有日期的商店参数,然后在商店中获取新数据并绑定(bind)到网格。并在网格上显示更新的数据?
提前致谢
这是创建网格的代码,点击创建一个按钮,需要将新参数传递给服务器
{
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);
更新=============================================
})
],
最佳答案
After getting data into the new store,you can use
grid.reconfigure(store, [columns])
to change which store is bound to the grid..Please have a look docs.
一个简单的工作fiddle
Update:Try this
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);
}
});
关于javascript - EXTJS GRID 和存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21456598/