开发者

How do I perform a refresh of the content of an Ext.NET GridPanel?

I have ext.net GridPanel on the page. GridPanel contains a button. How to force GridPanel refresh after button click?

UPDATE:

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 开发者_如何学Python=> row.RecordID))
              Facade.Vehicle.DeleteVehicle(Guid.Parse(key));


   //how to force GridPanel refresh?  
}


Let's say you have the data store GridStore1 assigned for your ext: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>

You could refresh the data of your GridPanel after any process by writing the following server-side code:

GridStore1.DataSource = Facade.Vehicle.List(); // your data object List or DataTable
GridStore1.DataBind();


If refreshing means reloading data you can use 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();
      }
    }],
  // ...
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜