嗨这是我的代码我试图刷新网格面板上点击工具栏中的刷新按钮,但它不再工作或没有任何反应你能帮我解释一下正确的语法吗?
var store = new Ext.data.JsonStore({
url: 'data-cloud.php',
fields: [{
name: 'userid'
}, {
name: 'record_name'
}, {
name: 'search_term',
type: 'string'
}]
});
var grid_array = new Array();
store.load({
params: {
start: 0,
limit: 5
}
});
store.on('load', function(store, records) {
for (var j = 0; j < records.length; j++) {
grid_array[j] = records[j].get('record_name');
}
});
// create the Grid
var datagrid = new Ext.grid.GridPanel({
store: store,
columns: [{
id: 'id',
header: 'Cloud Name',
width: 155,
renderer: record_name,
sortable: true,
dataIndex: 'record_name'
}, {
header: 'Search Term',
width: 150,
sortable: true,
dataIndex: 'search_term'
}],
stripeRows: true,
height: 250,
width: 500,
id: 'cloud_panel',
title: 'DB Grid',
id: 'detailPanel',
tbar: [{
text: 'Refresh',
iconCls: 'new-topic',
handler: function() {
Ext.getCmp('detailPanel').getView().refresh();
}
}
],
bbar: new Ext.PagingToolbar({
pageSize: 5,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});
答案 0 :(得分:0)
var grid = Ext.getCmp('cloud_panel');
...
tbar: [
handler: function() {
grid.load();
}
]
答案 1 :(得分:0)
如果刷新网格视图,数据将不再再次加载,它将重新呈现演示文稿。
要刷新实际数据,请使用网格商店中的reload功能:
Ext.getCmp('detailPanel').getStore().reload();
顺便说一下,你在网格配置中设置了id
属性两次,“cloud_panel”和“detailPanel”,所以你可能想要消除其中一个。
答案 2 :(得分:0)
尝试
var grid = Ext.getCmp('cloud_panel');
grid.getStore().load();
你也可以将params传递给商店
grid.getStore().getProxy().extraParams = {name:'name1', lname: 'lname'}
之后
grid.getStore().load(function(){
alert('store was loaded');
});