我在页面上有ext.net GridPanel。 GridPanel包含一个按钮。按钮点击后如何强制GridPanel刷新?
更新:
protected void btnDelete_Click(object sender, DirectEventArgs e)
{
var rsm = egrDrivers.SelectionModel.Primary as RowSelectionModel;
var selectedRowsCollection = rsm.SelectedRows;
foreach (var key in selectedRowsCollection.Select(row => row.RecordID))
Facade.Vehicle.DeleteVehicle(Guid.Parse(key));
//how to force GridPanel refresh?
}
答案 0 :(得分:2)
假设您为分机指定了数据存储 GridStore1:GridPanel GridPanel1:
<ext:GridPanel ID="GridPanel1" runat="server" Title="My Grid">
<Store>
<ext:Store ID="GridStore1" runat="server">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="RecordID" />
// ...
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="Record ID" DataIndex="RecordID" Width="100" />
// ...
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
通过编写以下服务器端代码,您可以在任何进程之后刷新 GridPanel的数据:
GridStore1.DataSource = Facade.Vehicle.List(); // your data object List or DataTable
GridStore1.DataBind();
答案 1 :(得分:1)
如果refreshing
表示reloading data
,您可以使用grid.store.load()
:
new Ext.grid.Panel({
// ...
store: yourStore,
// ...
bbar: [{
xtype: 'button',
text: 'refresh',
handler: function(btn){
var grid = btn.findParentByType('grid');
grid.store.load();
}
}],
// ...
});