Search code examples
extjsgridpanelext.net

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 => row.RecordID))
              Facade.Vehicle.DeleteVehicle(Guid.Parse(key));


   //how to force GridPanel refresh?  
}

Solution

  • 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();