1

我在页面上有 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?  
}
4

2 回答 2

2

假设您为您的ext:GridPanel GridPanel1 分配了数据存储GridStore1:

<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();
于 2011-08-06T17:48:13.500 回答
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();
      }
    }],
  // ...
});
于 2011-08-02T12:40:37.927 回答